I am currently trying to add a new string on the beginning of each line in a text file (temp.txt) and make a new file with combined text (newtemp.txt) using awk.
My code is:
awk " NR>1{printf \"=HYPERLINK(B%d, C%d) "\t" https://otrs.city.pittsburgh.pa.us/index.pl?Action=AgentTicketZoom;TicketID=%s\n\", NR-1, NR-1, $0}" temp.txt > untemp.txt
It is making a new file called untemp.txt that only has the string.
EX:
--------------------------------------------------------------------------------
=HYPERLINK(B2, C2) https://otrs.city.pittsburgh.pa.us/index.pl?Action=AgentTicketZoom;TicketID=
--------------------------------------------------------------------------------
=HYPERLINK(B3, C3) https://otrs.city.pittsburgh.pa.us/index.pl?Action=AgentTicketZoom;TicketID=
--------------------------------------------------------------------------------
=HYPERLINK(B4, C4) https://otrs.city.pittsburgh.pa.us/index.pl?Action=AgentTicketZoom;TicketID=
etc...
I want it to add the string above at the beginning of every line in the temp.txt.
It works in gawk but not awk.
What is the correct syntax, I am using Linux shell.
Thanks for the help!
awk ' NR>1{printf "=HYPERLINK(B%d, C%d) \t https://otrs.confidental/index.pl?Action=AgentTicketZoom;TicketID=%s\n", NR-1, NR-1, $0} ' temp.txt > newtemp.txtworked for me on Mac