I have a file which has 7375 lines and i need to add ls -l to the beginning of every line. How could i do this with sed?

marked as duplicate by Stéphane Chazelas sed Aug 11 '17 at 13:39

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

  • 2
    sed '/^/ls -l /' my_file ? – Stephen Rauch Aug 11 '17 at 13:16

Search for the beginning of a line with ^ and replace it with your desired string ls -l with sed's s/search/replace/

Your command would look like:

$ sed 's/^/ls -l /' file

Not the answer you're looking for? Browse other questions tagged or ask your own question.