Prefix and suffix strings to each output line from command

I have ran into a problem trying to write a Bash script. When grep outputs, it returns (usually) many lines. I would like to prefix and suffix a string to each of these output lines.

I would also like to note that I’m piping ls into grep, like:

ls | grep


With sed:

ls | grep txt | sed 's/.*/prefix&suffix/'

Leave a Reply

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