I have a text file where I want to append a column of numbers in ascending orders.
Input:
57 abc
25 def
32 ghi
54 jkl
Output:57 abc
57 abc 1
25 def 2
32 ghi 3
54 jkl 4
How do I go about doing that? Thanks!
I have a text file where I want to append a column of numbers in ascending orders.
Input:
57 abc
25 def
32 ghi
54 jkl
Output:57 abc
57 abc 1
25 def 2
32 ghi 3
54 jkl 4
How do I go about doing that? Thanks!
awk '{$3=NR}1' file
Thank you but this command does not really seem to work. Could it be because my input file is space delimited?
Can you post your input file using code tags?
1 rs9629043
1 rs3094315
1 rs2073813
1 rs3131968
1 rs2286139
1 rs12562034
1 rs2905035
1 rs12124819
1 rs2980319
Please follow the video tutorial on using code tags: Forum Video Tutorial: How to Use Code Tags
Sorry about that. I fixed the issue I think...
My code should be working for that input. What system are you using?
This is the output that I have been getting:
1 rs9629043
1
1 rs3094315
2
1 rs2073813
3
1 rs3131968
4
1 rs2286139
5
1 rs12562034
6
1 rs2905035
7
1 rs12124819
I use Ubuntu 11.04
Can you post output of:
cat -e input
Sure:
:
1 rs9629043^M$
1 rs3094315^M$
1 rs2073813^M$
1 rs3131968^M$
1 rs2286139^M$
1 rs12562034^M$
1 rs2905035^M$
1 rs12124819^M$
1 rs2980319^M$
You have copied this file from Windows it seems. Before running AWK, run:
dos2unix input