0

I have several files in a folder like this,

bob.txt
john.txt
bill.txt

I would like to create a list of this files and adding -v on every line like this,

-v bob.txt
-v john.txt
-v bill.txt

This is the command line to create a simple list, what about -v?

ls *.txt > output
user3224522
  • 1,119
  • 8
  • 19

2 Answers2

1

Try:

ls *.txt > output
sed -i -e 's/^/-v /' output

Referenced from here

The command on one line

(ls *.txt > output) && (sed -i -e 's/^/-v /' output)
Richard K Yu
  • 2,152
  • 3
  • 8
  • 21
0

for file in *.txt ; do echo -v $file; done

user1717259
  • 2,717
  • 6
  • 30
  • 44