![]() |
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here. |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Trim inside awk | subin_bala | Shell Programming and Scripting | 3 | 05-06-2008 08:51 AM |
| trim lines | melanie_pfefer | Shell Programming and Scripting | 6 | 03-26-2008 07:25 AM |
| combining fields in two text fields | shocker | Shell Programming and Scripting | 3 | 01-16-2008 11:27 AM |
| trim letters | fed.linuxgossip | Shell Programming and Scripting | 10 | 05-15-2007 10:11 PM |
| Trim | JWilliams | Shell Programming and Scripting | 4 | 04-24-2007 02:52 AM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
||||
|
trim fields using sed
Hello
I would like to trim any trailing spaces from a field before it is written to a file. Here is an example of the output string: Index ~Description~Keys ~Time ~ There can be any number of trailing spaces before the tilde I tried to use sed, and it sort of worked - it got rid of the trailing spaces but, it also removed the space between the words in the Description, which I don't want. Here is the sed command I used sed -e 's/[ ]*//g' file1 > file2 How can I modify this to delete the trailing spaces but keep the spaces between words? Any help would be greatly appreciated - Thanks! |
|
||||
|
sed 's/^[[:space:]]*\(.*\)[[:space:]]*$/\1/'
|
| Sponsored Links | ||
|
|
![]() |
| Bookmarks |
| Tags |
| awk, awk trim, trim, trim awk |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|