Adding patterns with increasing numbers at the end of every line

Hi All,

I have a file which has some Linux commands in every line like

more 456.dat
more 3232.dat
more 433.dat

I want to add texts like this at the end of every line:

more 456.dat > 1.txt
more 3232.dat > 2.txt
more 433.dat > 3.txt

So, that the result of more goes into 1.txt 2.txt and 3.txt respectively.

I know how to add numbers at the end of evry line

awk '{print $0 ,FNR}' file

But I don't know how to add other texts like > and .txt I am using Linux with BASH.

awk '{ print $0 " > " FNR ".txt" }' file

Awk uses juxtaposition as a string concatenation operator.

1 Like