Home > Software design >  List file names with -v symbol on each line
List file names with -v symbol on each line

Time:12-29

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

CodePudding user response:

Try:

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

Referenced from here

CodePudding user response:

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

  • Related