Hi gurus,
I need add one new line in the begining of current file.
current file
abc
cde
add
xyz
output file
newline
abc
cde
add
xyz
thanks in advance.
Hi gurus,
I need add one new line in the begining of current file.
current file
abc
cde
add
xyz
output file
newline
abc
cde
add
xyz
thanks in advance.
$ echo "newline" | cat - infile > outfile
$ cat <(echo "newline") infile >outfile
$ awk 'BEGIN{print "newline"}1' infile >outfile
sed '1i newline' infile
newline
abc
cde
add
xyz
cat - file <<< newline
Thanks for you reply.
when run the command, I got below error.
sed: command garbled: 1i newline
my server is SunOS 5.10 Generic_144488-17 sun4v sparc SUNW,SPARC-Enterprise-T5220
awk 'BEGIN { print "newline" } ; 1' inputfile > outputfile
If you want to use sed
, this should work:
sed '1i\
newline
' infile