I have this one :
sed -e 's/$/string after each line/' -i filename
but i want instead of "string after each line"
have a string from the following result:
cat filename2 | tr '\n' ' '
what should I do?
If I understand you correctly, you can just save this string in a variable like so:
$ myvar=`cat filename2 | tr '\n' ' '`; sed -e "s/$/ $myvar/" -i filename
Basically, you store the value of the command inside myvar
. Then, you run sed
and provide the contents of $myvar
as a string for the s
(substitute) command.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.