Q:

Running a command on each id in a text file

I have a text file with a list of id's like below and I need to run the below command on each of these ids,is there an easier way to do in awk? 
ssh -p 29418 company.com gerrit review --code-review 2 -- file.txt

file.txt contains below:
297003
297002
297001
...

Following commands should be run as long as an id exists in file.text
ssh -p 29418 company.com gerrit review --code-review 2 -- 297003
ssh -p 29418 company.com gerrit review --code-review 2 -- 297002
ssh -p 29418 company.com gerrit review --code-review 2 -- 297001
.....

A:

Awk isn't the tool I would jump for here.  I suggest xargs: 
xargs -I% -n1 < file ssh -p 29418 company.com gerrit review --code-review 2 -- %

The % character is the replace string as set with the -I option however as the replacement is at the end of the command in this case it does not need to be explicitly stated as xargs simply appends to the end by default:
xargs -n1 < file ssh -p 29418 company.com gerrit review --code-review 2 --

A tip is to use the echo command to see the output before you actually run it:
# -------------- notice we run echo not ssh to see the output before we rut it 
xargs -n1 < file echo ssh -p 29418 company.com gerrit review --code-review 2 -- 
ssh -p 29418 company.com gerrit review --code-review 2 -- 297003
ssh -p 29418 company.com gerrit review --code-review 2 -- 297002
ssh -p 29418 company.com gerrit review --code-review 2 -- 297001

Without the -n1 option xargs will passes all the values which may or may not be useful for this particular situation dependent on the usage of gerrit: 
xargs < file echo ssh -p 29418 company.com gerrit review --code-review 2 -- 
ssh -p 29418 company.com gerrit review --code-review 2 -- 297003 297002 297001

