![]() |
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 |
| Help removing lines with duplicated columns | yahyaaa | Shell Programming and Scripting | 14 | 05-17-2008 08:33 AM |
| Removing columns of a file using vi Editor | DilipPanda | UNIX for Dummies Questions & Answers | 2 | 02-08-2008 04:27 AM |
| Remove spaces from columns | jacks | Shell Programming and Scripting | 2 | 01-18-2008 10:08 AM |
| removing spaces | sahithi_khushi | Shell Programming and Scripting | 2 | 11-03-2006 11:20 AM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
removing spaces betweent columns
Hello Friends,
Can any one help me with this issue: I would like to format a file: say if I have rows like: 4512 , SMITH , I-28984 ,, 4324 , 4343 42312 , SMITH , I-2EE8984 ,, 432E4E4 , 4343 I would like to have the output diaplayed like : 4512 ,SMITH,I-28984,,4324, 4343 42312, SMITH, I-2EE8984 ,,432E4E4,4343 Thanks in advance for your help Sam ![]() |
|
||||
|
I have tried using
cat file_name.txt | tr -s " " "," this is overwriting the blank spaces S1234, A98 76 , A6789 , , , , A5677 , 3452 S9087 , A4562 , A1367 , A2678 , D7891 Displays: S1234,A98,76,A6789,A5677,3452 S9087,A4562,A1367,A2678,D7891 It should be: S1234,A98 76,A6789,,,,A5677,3452 S9087,A4562,A1367,A2678,D7891 Thanks |
|
|||||
|
Quote:
Code:
awk '{gsub(/ *, */,",")}1' infile
sed 's/ *, */,/g' infile
|
![]() |
| Bookmarks |
| Tags |
| awk, awk trim, trim, trim awk |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|