• Uncategorized

About linux : List-file-names-with–v-symbol-on-each-line

Question Detail

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

Question Answer

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)

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

You may also like...

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.