Hi,
I am use to using awk and sed. This time I have a file that has multiple columns. It looks like this:
4 6 7 8
5 4 3 2
3 2 6 9
I want to add chr to column 1 only so it looks like this:
chr4 6 7 8
chr5 4 3 2
chr3 2 6 9
The file is tab seperated.
Thanks
Phil
awk '{ $1="chr" $1; } 1' < datafile > outfile
make sure you specify the OFS (as you're re-eval-ing the record):
awk '{ $1="chr" $1; } 1' OFS=\t' < datafile > outfile
awk '{$0="chr" $0}1' infile > outfile
sed -i 's/^/chr/' file
bash-3.00$ sed 's/^./chr&/' /tmp/myfile
chr4 6 7 8
chr5 4 3 2
chr3 2 6 9
use sed -i to save the file with changes
alternate awk solution
awk '{print "chr" $0}' OFS=\t inptufile > outfile