I have a command that prints a single line.
I want to add/pipe this line to a file, just above its last line.
my_cmd | sed -i '$i' test
I just find an empty line in the correct place, above the last line.
I notice that when I add any string as '$i foo'
, the "foo" gets printed in the correct place, but I want the piped line to be printed.
How can I use STDIN instead of "foo"?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…