Another of my episodes just appeared on Hacker Public Radio. This time some tips that I use very often.
Tip 1: Repeating the same command using an infinite loop and a wait timer
while [ "x" = "x" ]; do ls -al ; sleep 5; done
If you find yourself repeating the same command over and over again then this tip may help. The example I gave in the episode was watching a file grow during a FTP transfer but this morning I used the same idea but did an ifconfig while I was waiting for a UMTS connection to establish.
About five minutes after posting the episode I noticed discovered that logic could be improved using while true instead. As in:
while true; do ls -al ; sleep 5; done
Tip 2: Speeding up podcasts
As Linc said on the Linux Linc Tech Show, there are a lot of podcasts out there and it’s difficult to get to them all. So this tip allows you to speed up the tempo of the podcast without affecting the pitch. So to make a long story short the podcasts are spead up without everyone sounding like Chipmunks. It takes a while to adjust to it but for spoken word it’s fine; for music it’s not so good.
sox in.mp3 out.ogg tempo 1.5
I’ve been using this tip since 2008-04-28. The reason I know this because that’s when I filed a bug with with Ubuntu beacuse their version of sox can convert from mp3 but not to mp3. It turns out this is also a problem with Debian. Unfortunately the ability to fix this is outside my skill set. My solution was just to convert everything to ogg and this works for me and my Samsung YP-U2.
Tip 3: Making an identical copy of a directory
Very often I need to copy a directory from one location to another but want to preserve things permissions, attributes, weird file names etc. The best tool for this job it tar. Rather than making a tar file, copying it and then extracting it as three separate steps, you can combine all the steps into one using.
tar -cf - . | ( cd /media/backupdisk; tar -xvf - )
Pingback: kenfallon.com » Blog Archive » faster: a bashpodder plugin
Thanks for the sox tip, didnt know that tool. always nice to see that others are enjoying the command line as much as i do. 😉
Regarding tip 1, most linux systems have the command “watch”, which does the same thing and can optionally highlight the differences in output
@Frido. Fantastic tip! Thanks a bunch I’ll add that to my unixtips.txt file.
@DoctorB: There seems to be a lot oc commandline love out there. This is the most feedback I’ve gotten on any hpr episode.