Results 1 to 3 of 3
I want to add a date to a record which is added to a file that gets its data from an external source. An explanation:
1. Getting external data: curl ...
- 05-19-2008 #1Linux User
- Join Date
- Dec 2004
- Posts
- 323
Adding a date as a column to a file
I want to add a date to a record which is added to a file that gets its data from an external source. An explanation:
1. Getting external data: curl http://www.download.com/scores.txt
2. Getting the required record: | grep myteam
3. Appending to file: >> myscores.txt
The question is not only to append the scores, but to add a column with the current date and time. So I need to add something like "$( date +%Y%m%d%H%M%S )" as the first column to scores.txt. How is this done?
Thanks in advance
- 05-22-2008 #2Linux User
- Join Date
- May 2008
- Location
- NYC, moved from KS & MO
- Posts
- 251
suppose the output of step 2 is /tmp/tmp_line, then the following command should do the job for you:
( date | tr '\012' '\t' ; cat /tmp/tmp_line )>>myscores.txt
'\t' is the separator between date and the score data, replace it with whatever you want. Add formatting string after date if you need to.
- 06-08-2008 #3Linux User
- Join Date
- Dec 2004
- Posts
- 323
Thanks, that worked after some more tweaking.


Reply With Quote