curl -s -u twitterusername:twitterpassword https://stream.twitter.com/1/statuses/sample.json -o "somefile $(date + format).txt"
format can be any one of the following:
%a : Abbreviated weekday name (Sun..Sat)
%b : Abbreviated month name (Jan..Dec)
%B : Full month name, variable length (January..December)
%d : Day of month (01..31)
%e : Day of month, blank padded ( 1..31)
%m : Month (01..12)
%Y : Year
%d : Day of month (e.g, 01)
%H : 24 hour format (00..23)
%I : 12 hour format (01..12)
%M : Minutes of the current time (00...59)
%j : day of year (001..366)
%D : date; same as %m/%d/%y
%F : full date; same as %Y-%m-%d
So, for you this will save the file and dynamically add the hour (%H) and the minutes (%M) of the current time
curl -s -u twitterusername:twitterpassword https://stream.twitter.com/1/statuses/sample.json -o "somefile $(date +\"%H:%M\").txt"
Because you want
curl to get data for 1 hour and save that data to the file resuming again operations you need to at least use a small script, this will do the job:
while true; do
curl -s -m 3600 -u twitterusername:twitterpassword https://stream.twitter.com/1/statuses/sample.json -o "somefile $(date +%H:%M).txt"
It will, while you leave the script running, execute the command, every 3600 seconds (1 hour, the
-m 3600 parameter) curl will close and the command will be gain executed.
Note that this will not just slit the stream, it will actually close curl and re-open it, do not think its possible to slit the stream while curl is running.
You need to same the script somewhere, ie
~/curl_script.sh and make it executable with
chmod 755 ~/curl_script.sh before using it on the terminal, to use it move the folder where the script was saved and just type
To interrupt the script press Ctrl+c.
If you interrupt the script and resume it on the same minute it will by default overwrite the previous collected data, so beware.
Let me know if you want to make some other modifications to the script. For further curl parameters I recommend the read of the curl man page (
man curl on a terminal).