Link to home
Create AccountLog in
Avatar of sunilbains
sunilbains

asked on

Removing tab from a column inside a file.

Hi All,
I haveone file which has 100 records each separated by "|". In some records, one column has tab . How can i delete tab form that column inside a file.
example
20080609|67961856|EQUITY PARTNERS 2004 EMPLOYEE FUND, L.P       |EQUITY PARTNERS 2004 EMPLOYEE FUND, L.P        |

There is a tab after L.P.
I used sed 's/^[ \t]*//;s/[ \t]*$//' .. but this didnot help for tab between line.

Can Somebody Help?

Avatar of ozo
ozo
Flag of United States of America image

sed 's/[ \t]*\|/|/g'
Avatar of sunilbains
sunilbains

ASKER

hi,
    iam getting following output..after tunning above command.
|2|0|0|8|0|6|0|9|||8|9|4|8|4|7|4|7|||M|a|t|s|u|m|o|i|n|c|.|||||P|r|i|v|a|t|e|P|l|a|c|e|m|e|n|t|||A|c|t|i|v|e|||2|0|0|3|0|1|2|0|||||0|.|0|0|||||||||||||||||||||||
I just need to remove "tab"  from records.
which version of sed are you using?
sid you try it without the \ in front of the |
GNU sed version 4.0.7
I dont want  to substitute tab with "|"
sed 's/[ \t]*\|/|/g'  ---  this is what this comand doing???
for below record,
20080609|67961856|EQUITY PARTNERS 2004 EMPLOYEE FUND, L.P       |EQUITY PARTNERS 2004 EMPLOYEE FUND, L.P        |

output should be
20080609|67961856|EQUITY PARTNERS 2004 EMPLOYEE FUND, L.P  |EQUITY PARTNERS 2004 EMPLOYEE FUND, L.P |




did you try it without the \ in front of the |
sed 's/[ \t]*|/|/g'  
Hi,
It worked..
But will it replace tab between two words with space  also?. or it will jon two words
for example EQUITY                 PARTNERS    will it be EQUITY PARTNERS  or EQUITYPARTNERS
sed 's/[\t*]//g'

should work. * character is inside the brackets.
Do you want it to replace tab between two words with space  also?.
hi,
I tried this command sed 's/[\t*]//g'
it worked fine for everything. So this command basicallt replace all TAB with nothing??
So instead of sed 's/[ \t]*|/|/g'    i can rely on sed 's/[\t*]//g'  for deleting tabs from the file ?
That will also delete any * character anywhere in the file?
the ^ or $ or | restricts it to only deleting next to the beginning of the line, end of the line or | character respectively
by saying substitute tab with space i ment that I dont want to join two words  after deleting tab between them
for example. EQUITY                 PARTNERS   should  be EQUITY PARTNERS  not  EQUITYPARTNERS
But i think command sed 's/[\t*]//g'  will not append two words. Correct me if iam wrong??
ASKER CERTIFIED SOLUTION
Avatar of ozo
ozo
Flag of United States of America image

Link to home
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
See answer