In a file, How do I replace a set number of characters in each line?
For example.... substitute the first 54 characters of each line with mv?
Thanks!
Lisa
In a file, How do I replace a set number of characters in each line?
For example.... substitute the first 54 characters of each line with mv?
Thanks!
Lisa
'sed' is your friend - sed1liners
sed 's/^.\{54\}/mv/' myFile.txt
sed "s/^.\{54\}/mv/" x
Thank you so much.... it was exactly what I needed!!
Can I just ask.... is the "." considered a wildcard in this code?
Yes "." matches any character
vgersh99
I have a doubt in this. If i am inside the file that is
vi myFile.txt.
Then how can I use the command, should I use the sed word?
no, but use the same 'substitute' expression in the vi 'command' mode.
Thanks,
could you please explain me what does this command mean?
:%s/crmrl01/crmpl01/g
:%s/crmrl01/crmpl01/g
: - vi command 'mode'
% - for ALL the lines in the files
s - substutute the following:
string 'crmrl01' with string 'crmpl01'
g - Globally for each line [not just once (by default), byut for multiple occorences of
string 'crmrl01'