其實最簡單的就是
$ export lines="text you want to append"
$ echo $lines >> file
$ echo "" >> file
If you don't mind using sed then,
$ cat test
this is line 1
$ sed -i '$ a\this is line 2 without redirection' test
$ cat test
this is line 1
this is line 2 without redirectionIf you just want to tack something on by hand, then the
sed answer will work for you. If instead the text is in file(s) (say file1.txt and file2.txt):Using Perl:
perl -e 'open(OUT, ">>", "outfile.txt"); print OUT while (<>);' file*.txtN.B. while the
============================================
>> may look like an indication of redirection, it is just the file open mode, in this case "append".============================================
If
lines="a\nb", then echo -e "a\n${lines}\n.\nwq" | ed filetoedit will adda
b
at the end of file.
EDIT: in fact there is an IO redirection. But perhaps it could help others.
沒有留言:
張貼留言