Issue
I have to add a 0 to the beginning of each row that has a number less than 10 in column 3. I am not sure how to specify that only these rows need to have a zero as
sed 's/^/0/'
will add a zero to all rows. Below is before and after of what I want to do where the difference appears in the first column (i.e. 9 becomes 09 but 10 does NOT become 010 since 10>9 in column 3). The fields are separated by a space.
9_99999468_A_G rs10981301:99999468:A:G 9 99999468
9_99999731_A_C rs79352914:99999731:C:A 9 99999731
9_99999825_A_AC rs148363074:99999825:A:AC 9 99999825
10_10000018_A_G rs6602381:10000018:A:G 10 10000018
10_100000625_A_G rs7899632:100000625:A:G 10 100000625
10_100000645_A_C rs61875309:100000645:A:C 10 100000645
10_100002841_C_CT rs146107628:100002841:C:CT 10 100002841
09_99999468_A_G rs10981301:99999468:A:G 9 99999468
09_99999731_A_C rs79352914:99999731:C:A 9 99999731
09_99999825_A_AC rs148363074:99999825:A:AC 9 99999825
10_10000018_A_G rs6602381:10000018:A:G 10 10000018
10_100000625_A_G rs7899632:100000625:A:G 10 100000625
10_100000645_A_C rs61875309:100000645:A:C 10 100000645
10_100002841_C_CT rs146107628:100002841:C:CT 10 100002841
Solution
Using awk
:
$ awk '$3 < 10 { $1 = "0" $1 } 1' input_file
Answered By - Shawn Answer Checked By - David Goodson (WPSolving Volunteer)