Reputation: 10484
is there any shell command to insert a string of characters in every line of a file.. < in the beginning or the end of every line >
Upvotes: 0
Views: 2181
Reputation: 4822
linecount=0
while IFS= read -r LINE; do
echo "$((linecount++)) START $LINE END"
done < file
If you want to do fancier manipulation of the linecount:
linecount=0
while IFS= read -r LINE; do
let linecount++
echo "$((linecount-5)) START $LINE END"
done < file
Upvotes: 0
Reputation: 361937
sed -i 's/^/Before/' file.txt
sed -i 's/$/After/' file.txt
Upvotes: 3
Reputation: 4822
Lots of them.
This will work:
sed -i -e 's/.*/START & END/' file
Upvotes: 6