How to insert a tab at beginnning of a line AND do some replacement?
Hey
I have tried to replace some symbols with tab, using sed command: Code:
sed 's/[\t;, ]\{1,\}/\t/g' file Code:
sed 's/^/\t/g' file Can anybody help me with this? THX! |
Try throwing in a pipe (|) between the 2 regexes and I would probably include -r switch so you don't have to escape it.
|
Actually, you have three options.
1) Use multiple expressions with the -e option. Code:
sed -r -e 's/[\t;, ]+/\t/g' -e 's/^/\t/g' file Code:
sed -r 's/[\t;, ]+/\t/g ; s/^/\t/g' file Code:
sed -r 's/(^|[\t;, ]+)/\t/g' file Here are a few useful sed references: http://www.grymoire.com/Unix/Sed.html http://sed.sourceforge.net/grabbag/ http://sed.sourceforge.net/sedfaq.html http://sed.sourceforge.net/sed1line.txt |
thank you guys!!i have solved my problem :D
|
All times are GMT -5. The time now is 06:38 PM. |