I want to add a " character to the begin of every line in a text file. Is there any simple solution?
perl -p -e 's/^/"/' myfile
should do it!
$ cat myfile
0
1
2
3
4
5
6
7
8
9
10
$ perl -p -e 's/^/"/' myfile
"0
"1
"2
"3
"4
"5
"6
"7
"8
"9
"10
Another couple of suggestions:
just in the shell:
tmp=$(mktemp)
while read -r line; do printf '"%s\n' "$line"; done < filename > "$tmp" &&
mv "$tmp" filename
ed:
ed describes.sql.bak <<'END'
1,$s/^/"/
w
q
END
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With