![]() |
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 |
| echo seems to trim whitespace | joeyg | Shell Programming and Scripting | 2 | 02-28-2008 04:41 PM |
| TO break a line | aajan | Shell Programming and Scripting | 7 | 08-28-2007 04:12 AM |
| To Trim spaces at the end of line | sbasetty | Shell Programming and Scripting | 1 | 01-31-2007 10:01 PM |
| Trim trailing spaces from each line in a file | tipsy | Shell Programming and Scripting | 5 | 09-13-2006 05:48 AM |
| trim whitespace? | msteudel | Shell Programming and Scripting | 4 | 07-07-2005 07:57 PM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
Trim whitespace and add line break
All,
I'm a newbie at shell scripting and regular expressions and I just need to take a file that's arranged like the one below, remove all leading and trailing whitespace and add a line break after each word. I've been able to remove a few spaces using various awk, sed and Perl scripts, but without much success beyond that. I appreciate any assistance. ################ ex: HTML Code:
dog cat moose telephone
house red talk
balloon deer banana
Thanks so much in advance. Moose |
|
|||||
|
Quote:
awk '$1=$1' RS=" " infile # use nawk on Solaris or /usr/xpg4/bin/awk NF RS=" " infile # on Solaris or gawk NF RS=" " infile |
![]() |
| Bookmarks |
| Tags |
| awk, awk trim, regex, regular expressions, trim, trim awk |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|