Coredump
Work, play, and everything in-between [feed]

Posts Tagged ‘bash’

Find duplicate files

Update: As Pádraig Brady, fslint maintainer, pointed out: fslint/findup *is* a shell script.
My 500-GB Seagate FreeAgent Desktop is almost filled to the brim (there’s *only* ~70GB free space left) so I need to find all duplicate files for clean-up.
Fortunately, there are tools to do just this. I tried fslint, which is also available in [...]

Get Twitter timeline from the CLI

We already know how to update Twitter from the command line. To get your and your friends’ timeline from the CLI, use the following one-liner:

curl -u username –silent "https://twitter.com/statuses/friends_timeline.rss" | perl -ne ‘print "$2\n" if /< (description)>(.*)< \/\1>/;’

Using the same method, you can also get unread Gmail inbox messages (via commandlinefu.com).

Quick directory switching

At work, I do a lot of directory traversal: going from one location to another within the whole (global) filesystem structure. So, to conveniently go back to a previous directory, I use pushd and popd, aside from the usual cd:

$ pwd
/home/iandexter
$ pushd /etc/sysconfig
$ pwd
/etc/sysconfig
$ popd
$ pwd
/home/iandexter

You can even echo $DIRSTACK to list the current directories [...]

Twitter updates, via CLI

I’ve just started using Twitter, an up-and-coming web service that posts user status on the web, in IM and in SMS. The service also exposes its API, so it’s possible to build apps using it.
I found a nifty way of updating my Twitter status through the command line:

curl -u username:password -d status=’status_goes_here’ -s http://twitter.com/statuses/update.xml > [...]

FizzBuzz

Hmmm…
In Bash, I would have done:

$ for i in `seq 100` ; do if [ `expr $i % 15` -eq 0 ] ; then echo FizzBuzz; elif [ `expr $i % 3` -eq 0 ]; then echo Fizz; elif [ `expr $i % 5` -eq 0 ]; then echo Buzz; else echo $i; fi; [...]

« Before