Results 1 to 3 of 3
Let's say I have only one line in alien.x like this:
Code:
humans
And I wanted to append to the end of that line this:
Code:
=food
How would I ...
- 09-10-2007 #1
Append text to the ending part of a line?
Let's say I have only one line in alien.x like this:
And I wanted to append to the end of that line this:Code:humans
How would I do that so it looks like this:Code:=food
??Code:humans=food

- 09-10-2007 #2Linux Enthusiast
- Join Date
- Aug 2006
- Posts
- 631
Some possibilities:
Code:sed 's/humans/humans=food/'
Code:sed 's/\(.*\)/\1=food/'
RegardsCode:awk '{printf("%s=food", $0}'
- 09-10-2007 #3
A common way is also:
This replaces the end-of-line marker (denoted by '$') with the test '=food'. '$' isn't actually in the file (it's what regular expressions call an "anchor", so this doesn't actually replace anything.Code:sed 's/$/=food/'
DISTRO=Arch
Registered Linux User #388732


Reply With Quote