Artificial intelligent assistant

While read from file with sequence number I want to write a file using echo command. The echo commend will get data from anther file. Here is the echo command: echo '{ name: $name id: $seq } I have a txt file: customer 1 customer 2 customer 3 So I want to generate a file doing echo and replace $name from fist line from the txt file. And then replace $seq start with 1. This is the file i want. { name: customer 1 id: 1 } { name: customer 2 id: 2 } { name: customer 3 id: 3 } While reading first line, the ID should be 1, while reading second line the ID should be 2`

try


awk '{printf "{\
\tname: %s\
\tid: %d\
\t}\
",$0,NR}' file.txt


where

* `printf` will skip line, add tab and format string.



for `id:` argument, you can either use second field in your sample file, or generate one from line number (that is `NR` (Number of Record) value).

xcX3v84RxoQ-4GxG32940ukFUIEgYdPy 09aa68a14059b77a30ff115f2d83942f