Hello,
I am processing data. In the first column there is the date ("2011 02 03 12 45") separated by space and follow I have the measurements.I have several days in one file. What I would like to do is:
to read the data line by line and write the data of "today" in a new file and "yesterday" as well in another file, separated by TAB and the date should be in the form of "2011/02/03 12:45:00".(today and yesterday is already defined in another script).
something like that I thought it might be an approach but I am just beginning to write scripts...
Well I'm just starting out too.
I think this would probably easier to handle w/ awk, but since I'm wrapping my head around sed I thought I would give it a go.
I've got some things to do, I'll be back and we'll see where you are.
Here's a start to get the data in the right way-
s/ /\//
s/ /\//
s/ /:/2
s/ /:00 /2
Now you just have to output it to the right places.
Have at it!
---------- Post updated at 04:28 PM ---------- Previous update was at 04:25 PM ----------
Oh and run as a sed script, presuming the data is in awk-data, the command will look like this at the command prompt-
> sed -f sed-script4 < awk-data
With the contents of sed-script4 being what I posted above this.
Capiche?
Thanks for your help.If have done it on that way and the date format is ok:
for station in 62105 62081
do
grep "^$yesterday" $station.txt | sed -e 's/ /\//' -e 's/ /\//' -e 's/ /:/2' > output_today
grep "^today" $station.txt | sed -e 's/ /\//' -e 's/ /\//' -e 's/ /:/2' > output_yesterday
done
Now i just want to remove the blanks by Tab. The problem is that sometimes I have 1 backspace sometimes 2 or 3 or more between the columns and I have no idean how to solf the problem
"its not working" means that it is doing nothing. the files are like the original files (separated with blanks not with tab), just the data format is correct.