Hi,
I'm very new in Linux operating system. I've started looking at different types scripting and trying to manipulate one of the large text files that I'm using to run a simulation of coastal flooding. Following is the text file:
Code:
FileVersion = 1.03
Filetype = meteo_on_curvilinear_grid
TIME = 0 hours since 1900-01-01 12:00:00 +00:00
-6.855 -6.828 -6.801 -6.774 -6.747 -6.719 -6.691 -6.663 -6.634 -6.606 -6.577 -6.548 -6.519 -6.489
TIME = 0 hours since 1900-01-01 12:00:00 +00:00
-6.855 -6.828 -6.801 -6.774 -6.747 -6.719 -6.691 -6.663 -6.634 -6.606 -6.577 -6.548 -6.519 -6.489
TIME = 0 hours since 1900-01-01 12:00:00 +00:00
-6.855 -6.828 -6.801 -6.774 -6.747 -6.719 -6.691 -6.663 -6.634 -6.606 -6.577 -6.548 -6.519 -6.489
TIME = 0 hours since 1900-01-01 12:00:00 +00:00
-6.855 -6.828 -6.801 -6.774 -6.747 -6.719 -6.691 -6.663 -6.634 -6.606 -6.577 -6.548 -6.519 -6.489
The file is very large; around 78 MB. I just shortened it to the first few lines. If you notice carefully, all the times are showing 0 hours and for
1900-01-01 12:00:00 +00:00 time periods. I wanted all the
1900-01-01 12:00:00 +00:00 to change in to
2016-10-03 12:00:00 +00:00 . And I did this by using
Code:
sed -i 's/1900-01-01/2016-10-03/g' file.txt
but I also want to change all the time which are showing
0 hours
Code:
TIME = 0 hours since
to change 6 hourly intervals so that it becomes like this:
Code:
TIME = 0 hours since
TIME = 6 hours since
TIME = 12 hours since
TIME = 18 hours since
The output that I'm trying to get finally is something like this:
Code:
FileVersion = 1.03
Filetype = meteo_on_curvilinear_grid
TIME = 0 hours since 2016-10-03 12:00:00 +00:00
-6.855 -6.828 -6.801 -6.774 -6.747 -6.719 -6.691 -6.663 -6.634 -6.606 -6.577 -6.548 -6.519 -6.489
TIME = 6 hours since 2016-10-03 12:00:00 +00:00
-6.855 -6.828 -6.801 -6.774 -6.747 -6.719 -6.691 -6.663 -6.634 -6.606 -6.577 -6.548 -6.519 -6.489
TIME = 12 hours since 2016-10-03 12:00:00 +00:00
-6.855 -6.828 -6.801 -6.774 -6.747 -6.719 -6.691 -6.663 -6.634 -6.606 -6.577 -6.548 -6.519 -6.489
TIME = 18 hours since 2016-10-03 12:00:00 +00:00
-6.855 -6.828 -6.801 -6.774 -6.747 -6.719 -6.691 -6.663 -6.634 -6.606 -6.577 -6.548 -6.519 -6.489
Is it possible to conduct both the operations by using a single loop combining sed and awk operations. Can anyone suggest me which options would be best here? That'd be very helpful for my work.
Thanks in advance.