Add prefix to each line of output with sed -
okay after googling minutes seems regular way prefix each line of output sed
but error don't understand.
what mean , how can fix this?
$ sed 's/^/#/' test.txt sed: -e expression #1, char 0: no previous regular expression
what test.txt looks - it's test
### test.txt b c d e f g h
oh yeah.. version
$ sed --version gnu sed version 4.2.1 copyright (c) 2009 free software foundation, inc. free software; see source copying conditions. there no warranty; not merchantability or fitness particular purpose, extent permitted law.
below code same using capturing group won't touch blank lines.
sed 's/^\(.\)/#\1/' test.txt
try if want add #
@ start of blank line also.
sed 's/^\(.\|\)/#\1/' file
example:
$ cat f b $ sed 's/^\(.\)/#\1/' f #a #b $ sed 's/^\(.\|\)/#\1/' f #a # #b
Comments
Post a Comment