how to replace line of file with another line using awk in shell script
I have a file that contains line
MXST6MXDT:Mexico City Daylight:5,1-7:+1:9,24-30:0 I want to replace above line with the following line MXST6MXDT:Mexico City Daylight:4,1-7:+1:10,25-31:0 how do i do it using shell script Amit |
If it's just one file, just edit it. The only reason for a script is if you need to do it several times.
To write a script, you need to define the decision logic. e.g.: Are you going to act on every line containing "Mexico City"? Or maybe you just want to change every instance of "5,1-7:+1:9,24-30:0" to "4,1-7:+1:10,25-31:0" ..? Here is one of many possible solutions: Code:
sed '/Mexico/s/5,1-7:+1:9,24-30:0/4,1-7:+1:10,25-31:0/ filename > newfilename |
Code:
sed -i 's/MXST6MXDT:Mexico City Daylight:5,1-7:+1:9,24-30:0/MXST6MXDT:Mexico City Daylight:4,1-7:+1:10,25-31:0/' file.txt |
Hey.
These lookslike entries in the task scheduler. 'at`, `cron` etc. Why do it programatically when you can generate the code for 25th to 31st. Have a slightly different name and for both call the same functional routine. End |
All times are GMT -5. The time now is 11:49 AM. |