Hi, I have data of the following type,
chr1 234 678 39 852 638 abcd 7895
chr1 526 326 33 887 965 kilj 5849
Now, I would like to have something like this
chr1 234 678 39 852 638 abcd 7895 <a href="http://unix.com/thread=chr1:234-678">Link</a>
chr1 526 326 33 887 965 kilj 5849 <a href="http://unix.com/thread=chr1:526-326">Link</a>
basically, this is nothing but first column separated by a colon ":" and the second and third columns with a hyphen "-".
My files has around 20000 records.
All helps appreciated. Thanks
awk '{$0=$0" <a href=\"http://unix.com/thread="$1":"$2"-"$3"\">Link</a>"}1' infile > outfile
awk '{printf "%s <a href=\"http://unix.com/thread=%s:%s-%s\">Link</a>\n",$0,$1,$2,$3}' infile
Thanks scrutinizer and bartus.
But, the last column is being printed without a tab in between.
How do I add a tab between the last and pre-last column?
Thanks
Here?
awk '{$0=$0"\t<a href=\"http://unix.com/thread="$1":"$2"-"$3"\">Link</a>"}1' infile > outfile
Not sure what you means with the last column. Do you mean this?
awk '{printf "%s\t<a href=\"http://unix.com/thread=%s:%s-%s\">Link</a>\n",$0,$1,$2,$3}' infile