A couple of days ago, I typed in the following one-liner:
$ sleeptil -v 19:00; while [[ -z $(chk-jtv-lives.sh) ]]; do sleep 1m; done; beeps Thu Dec 27 19:00:00 CST 2012 in 37 minutes 18 seconds
What it did was:
- Wait until 7 PM using sleeptil,
- Check chk-jtv-lives.sh if it outputs anything,
- If not, sleep for one minute, then go to #2,
- If yes, leaves the loop, and runs beeps.
There is a channel which broadcasts around 7:30 PM every day, sometimes, it does, sometimes, it doesnt. I dont need to check or keep press refresh button to know if the stream is live or run that checking script. Just let this one-liner run and I will hear beeping noise when the stream goes live.
When I wrote those scrips and functions, I didnt know one day I would use all of them in a one-liner. No need for a special app or browser add-on, just piece together a few codes that I have written and I have a unique and custom-made notifier.
It may not look epic or fancy as any other notifier, but it tells me: When you write a useful code and you will know it eventually. Not only it helps you but also saves your time.
I really like shell scripting, you can use Bash to do many tasks. Oftentimes, a simple one-liner does the task perfectly, and that makes you feel great.
Have you had similar experience?
Yes, I love shell scripting, its so freaking useful and despite what people may think its used in lots of places, such as in the bash completion functionality, in init.d | upstart scripts, debian packaging, etc. Of course the situations similar to the one you describe here are also great, you feel youve the perfect tool right a way and the fact you can build it in minutes is awesome.
ReplyDeleteYep, that kind of feeling is great.
ReplyDeleteAnd if you crazy enough you can do really a lot with Bash, but usually thats just like someone asks you why, then you answer "because I can."
The most craziest thing I have done with Bash is probably an OAuth library, or this Last.fm scrobber for mplayer. Why? Because I can, but its really not worth.
Recently, I stumbled on a shell unittest library shUnit2, I am still waiting for a good chance to use it.
One-liner in Bash is much better than those crazy stuff, IMHO!