- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - Linux
- >
- Unalbe to remove "tab" character using "sed"
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Discussions
Discussions
Discussions
Forums
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО02-13-2008 03:04 AM
тАО02-13-2008 03:04 AM
Unalbe to remove "tab" character using "sed"
Trying to remove a tab character using sed as follows.
sed 's/[ \t]*$//' file_name.txt
But it is not removing the tab space as expected. To remove the tab space, again ran the sed as follows.
sed 's/[ ]*$//' file_name.txt ( here insted of "\t" used the tab key .
Can anybody help to resolve this.
Regards,
Raghu.
- Tags:
- sed
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО02-13-2008 04:57 AM
тАО02-13-2008 04:57 AM
Re: Unalbe to remove "tab" character using "sed"
Not all 'sed' variations support the '\t' escape character.
Using the TAB key as you did is valid.
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО02-13-2008 07:32 PM - edited тАО09-17-2011 01:23 PM
тАО02-13-2008 07:32 PM - edited тАО09-17-2011 01:23 PM
Re: Unable to remove "tab" character using "sed"
>JRF: Not all 'sed' variations support the '\t' escape character.
I don't see it documented in sed(1), or ed(1) or in regexp(5).
tr(1) mentions it takes \ then octal digits.
You could use a character class:
sed 's/[:space:]*$//' file_name.txt
Or:
$ sed -e "s/$(echo "[ \t]\c")\*$//" file_name.txt
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО02-14-2008 05:49 AM
тАО02-14-2008 05:49 AM
Re: Unalbe to remove "tab" character using "sed"
> Dennis: >JRF: Not all 'sed' variations support the '\t' escape character.
> Dennis: I don't see it documented in sed(1), or ed(1) or in regexp(5).
My remark was based both on experience and on the reference "...that the only C-like backslash sequences that you can portably assume to be interpreted are \n and \\; in particular \t is not portable, and matches a `t' under most implementations of sed, rather than a tab character."
...from:
http://www.gnu.org/software/sed/manual/sed.html
I too thought about suggesting the '[:space:]' character class, but rejected that since the author specifically asked about the '\t' escape and not the more generalized "whitespace" (space, tab, etc.).
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО02-14-2008 03:56 PM - edited тАО09-17-2011 01:24 PM
тАО02-14-2008 03:56 PM - edited тАО09-17-2011 01:24 PM
Re: Unable to remove "tab" character using "sed"
>JFF: My remark was based both on experience and on the reference
My comment about the documentation was that it didn't mention allowing it.
>I too thought about suggesting the '[:space:]' character class,
I suggested it since the above RE had a space AND a tab, so why not go for broke. :-)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО02-14-2008 11:25 PM
тАО02-14-2008 11:25 PM
Re: Unalbe to remove "tab" character using "sed"
Thanks for addressing the problem. It helpmed to resolve the issue.
regards,
raghu.