Script for pulling data out of a txt file
I would like to write a script that pulls the last line of data out of a txt file and then saves it to another txt file. The txt file that I am looking at resides here.
http://www.swpc.noaa.gov/ftpdir/list...ulder_iono.txt I know I can grab that file using wget. I've done a little scripting but nothing major. Can someone push me in the right direction? Thanks, |
Hi,
This will grep the last line of the mentioned file and saves it in foo.txt: wget -qO - http://www.swpc.noaa.gov/ftpdir/list...ulder_iono.txt | tail -1 > foo.txt Hope this helps. |
tail -n 1 > somewhere
|
Quote:
|
You're welcome :)
|
Is there a way to grab a specific line number? Say if I also wanted to grab the following out of the text.
# YR MO DA HHMM foF2 hmF2 MUF(D) D h'F yF2 fMUF h' fxI foF1 foE hmE foEs fbEs ITEC |
Hi,
It is probably not clear to me what is is you want. You want something like this as output ("header" and the last line)?: # YR MO DA HHMM foF2 hmF2 MUF(D) D h'F yF2 fMUF h' fxI foF1 foE hmE foEs fbEs ITEC 2010 08 03 1600 5.7 305 3.24 3000 305 86 5.3 325 6.4 4.6 3.2 105 3.7 -1.0 10.0 If that is the case: wget -qO - http://www.swpc.noaa.gov/ftpdir/list...ulder_iono.txt | sed -ne '/# YR MO DA HHMM/p' -e '$p' > foo.txt If not please elaborate (with an example?). |
Quote:
I am unable to get it to work though. Foo.txt outputs 2010 08 03 1730 5.7 295 3.12 3000 190 90 4.6 270 6.3 4.6 3.4 100 3.6 -1.0 11.2 |
All times are GMT -5. The time now is 09:27 PM. |