how would you get SED to do the following, say you have the following lines in a text file:
user=tigger
some text some text
some text some text
some text some text
user=ted
some text some text
some text some text
some text some text
user=thekingofrockandroll
you want to find any line which has 'user=[the user name]' and replace it with 'user=xxx'
so the string after the 'user=' will always contain a different number of characters but you just want to sed to find any lines with 'user=' and replace the part after 'user=' with 'xxx' no matter what?
and...
if what to replace say 'AM' in a text file with 'JO', i can do:
sed 's/AM/JO/g;s/am/jo/g'
but what if the text file where i'm running this looks like this:
AM
TAME
am
jammy
I only want to replace the following lines with 'JO':
AM
am
so I want to leave 'TAME' and 'jammy' in there - the sed above will give this:
hmm, what I would like ideally is this (say I'm replacing JO with BO)
my file to run sed on looks like this (as an example):
akdjfdkl sdjfklsjdf jsdfkljsf JO KSJDFKDFJLJOdsjfskldjf dsjfkljsfl <---- first JO on this line should be replaced by sed, second one should not because it forms part of a word
akdjalsd@JO <--- JO should be replaced here by sed
sdfkjdslfjsl@dfdsf_JO <----- and here
JO <---- and here
jo <----- and here
If you want to differentiate between upper and lower case, then ommit the "i" modifier. I think "i" also modifies behaviour of character range brackets, so A-Z needs to be added.