awk question
Hello,
I have a tab separated text file which I'd like to separate by commas instead. I use the following command: Code:
awk -v OFS=':' '$1=$1' file How do I just replace the TABs but not the spaces? Thanks, |
Make tab the input delimiter:
-F\\t or -v FS='\t' simpler and more readable to not use awk though; sed -e 's/\t/:/g' file |
sed would be a good tool for that
|
awk
Code:
awk '{gsub("\t",":")}1' file |
Thanks, ghostdog74
Unfortunately this doesn't seem to work for me. Quote:
Is there anything else I can try? Thanks, |
Hi,
These all work for me: cat infile | tr "\t" ":" sed 's/\t/:/g' infile --> acid_kewpie's solution from post #2 awk '{gsub("\t",":")}1' infile --> ghostdog74's solution from port #4 |
@OP if you want more "precise" answers, provide more information about your data files and the output you want. Help us to help yourself.
|
why do some people only ever read the last reply??? What was wrong with the two solutions i gave??
|
All times are GMT -5. The time now is 07:53 PM. |