Issue
I have some lines down below and I'm trying to append "Check" to the line that starts with Apples. Does someone know how I can get "Check" on the same line as Apples, not a new one and print the output? I wasn't getting anywhere on my own.
Thanks
What I have:
Grocery store bank and hardware store
Apples Bananas Milk
What I want:
Grocery store bank and hardware store
Apples Bananas Milk Check
What I tried:
sed -i '/^Apples/a Check' file
What I got:
Grocery store bank and hardware store
Apples Bananas Milk
Check
Solution
This might work for you (GNU sed):
sed '/Apples/s/$/ check/' file
If a line contains Apples
append the string check
. Where $
represents an anchor that is the end of the line (see here).
Answered By - potong Answer Checked By - Robin (WPSolving Admin)