How do I append a string that has variables in it?
sed 's/MIMG109AL1ARP\t[[:alnum:]]*\t/ /g'
I initially thought sed
, but I don't want to replace anything, I want to add something after the intial line.
Some example strings are as follows:
MIMG109AL1ARP PQHDO0542I7537
MIMG109AL1ARP PQHDO0372I2435
MIMG109AL1LLL QRHDO0382I2342
MIMG109AL1LLL PQHDO362I2345
However I want them to look like this:
MIMG109AL1ARP PQHDO0542I7537 appendagehere
MIMG109AL1ARP PQHDO0372I2435 appendagehere
MIMG109AL1LLL QRHDO0382I2342 appendage2here
MIMG109AL1LLL PQHDO362I2345 appendage2here
Just edited the file to make my question more clear! I need to append separate lines separately, not every line. Thank you for your input so far. Any help or redirection is appreciated!
awk '$1~/^[A-Z]/ {print $0 "\tappendagehere"}' file
... Or, if you wantsed
:sed '/^[A-Z]/ s/$/\tappendagehere/' file
vi
and learn to love theA
(append to end-of-line) and.
(repeat-last-command) commands. for a few dozen or a few hundred lines it's often easier and quicker to edit manually with a decent editor (such as vi).