![]() |
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 |
| UNIX for Advanced & Expert Users Expert-to-Expert. Learn advanced UNIX, UNIX commands, Linux, Operating Systems, System Administration, Programming, Shell, Shell Scripts, Solaris, Linux, HP-UX, AIX, OS X, BSD. |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Of bash and whitespace... | lev_lafayette | Shell Programming and Scripting | 2 | 04-13-2008 08:44 PM |
| Delete whitespace | truck7758 | Shell Programming and Scripting | 12 | 12-05-2007 12:00 PM |
| sed : remove whitespace | b.hamilton | Shell Programming and Scripting | 3 | 11-06-2007 11:02 AM |
| trim whitespace? | msteudel | Shell Programming and Scripting | 4 | 07-07-2005 07:57 PM |
| remove whitespace and test | bensky | Shell Programming and Scripting | 4 | 09-25-2003 08:02 AM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
sed and whitespace characters
I have teh follwing details in a file:
SmithA..... ,,400 JonesA..... ,,300 JamesA..... ,,600 BakerA ,,800 ChrisA ,,1200 the first field name is 6 characters in length always and alays ends with an 'A'. The periods denote white space (space caharacters), as you can see on certain occurences ther are many 'spaces' and in other instances no 'spaces'. I want to be able to make the above file as below: SmithA. ,,400 JonesA. ,,300 JamesA. ,,600 BakerA. ,,800 ChrisA. ,,1200 So anly one single whitespace is present after the las 'A' character. I have treied the following, sed 's/ *//g' fileA > fileB which gives me: SmithA ,,400 JonesA ,,300 JamesA ,,600 BakerA ,,800 ChrisA ,,1200 however i am now not so sure how to put a whitecase character back in after the A to get the format as required above. Could anyone assist, also would perferably be ideal if i could have the whole thing processed in one single sed command. |
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|