-4

Suppose I have a file with 3 lines:

output.txt:

Maruti
Zen
Suzuki

I used the command wc -l output.txt to get no. of lines i got output as 3

Based on the above output I have to execute a command

echo CREATE FROM (sed -n 1p OUTPUT.txt)
echo CREATE FROM (sed -n 2p OUTPUT.txt)
echo CREATE FROM (sed -n 3p OUTPUT.txt)
:
:
echo CREATE FROM (sed -n np OUTPUT.txt)

Can you please suggest a command to replace 1 2 3 .....n in the above command based on the output i get (i.e., no. of lines in my file)

I just gave a sample explanation of my use case. Please suggest a command to execute n no. of times.

1 Answers1

0

You just need one command.

sed 's/^/CREATE FROM /' output.txt

See also Counting lines or enumerating line numbers so I can loop over them - why is this an anti-pattern?

tripleee
  • 175,061
  • 34
  • 275
  • 318