Closed ChunkOfStars closed 10 years ago
I think you have a couple of usage problems here.
The & in your argument to twurl is getting interpreted by your shell and putting the twurl process in the background. This ends up not doing what you want with your pipeline. You can get around that by quoting the whole thing like this:
twurl "/1.1/statuses/user_timeline.json?screen_name=userxyz&count=1"
Next is that the output from twurl is going to be json, in one single line, and that is not at all friendly to line oriented filters like grep. To solve this problem you should pipe to a json pretty printer and then grep, or better yet pipe it to 'jq' (which you'll need to install from somewhere) and let that parse and manipulate the json. In your example you'd do this to print just the id_str (check jq man page for lots of ways to manipulate the json):
twurl "/1.1/statuses/user_timeline.json?screen_name=userxyz&count=1" | jq .[].id_str
For an probably-built-in json pretty print you could go with python like this:
twurl "/1.1/statuses/user_timeline.json?screen_name=userxyz&count=1" | python -m json.tool
Thank you.
unless I am doing something wrong, i am not able to do anything with what the program returns.
for example twurl /1.1/statuses/user_timeline.json?screen_name=userxyz&count=1 | grep -i id_str or twurl /1.1/statuses/user_timeline.json?screen_name=userxyz&count=1 > test.txt
both return a ton of information, they ignore the pipes and redirects