The shell one line script below will:

1. Find all files below current dir
2. Rename the file with download Source and date range as part of the new file name
3. Renamed file will stay at current location (e.g. file “./path/to/dir/crappyname” becomes “./path/to/dir/DC.Circuit-2006.06.02-2006.07.01.txt”)

Read the rest of this entry…

With User Private Groups, umask of 002 or 007 makes more sense than the traditional umask of 022 when multiple users are working with shared files. Libpam-umask is handy for overriding the default umask setting.

Starting with Debian Lenny, libpam-umask is part of libpam-modules (which was auto installed on every Debian Lenny setup I’ve done so far), so just need to add the following to “/etc/pam.d/common-session”:

session    optional     pam_umask.so umask=002

Read the rest of this entry…

To trim a video clip, mencoder and ffmpeg expect a start time in hh:mm:ss, but instead of end time, want duration:

$ mencoder -ss 00:02:55 -endpos 00:07:15 -oac copy -ovc copy in.avi -o out.avi
$ ffmpeg -ss 00:02:55 -t 00:07:15 -vcodec copy -acodec copy -i in.avi out.avi

Video players make it easy to identify start/stop times, but difficult to figure out duration, so I wrote a little shell script that will calculate duration from start/stop times.

Usage example:

$ calc-duration 00:02:55 00:10:10
 
 Start: 00 hrs 02 min 55 sec
 Stop:  00 hrs 10 min 10 sec
 
 +----------------------+
 | duration is 00:07:15 |
 +----------------------+

Read the rest of this entry…

Display all lines from file except lines between two lines matching a pattern:

1
sed '/10\/02\/1992/,/01\/02\/2001/d' input.txt

Display lines between two lines matching a pattern:

1
sed -n '/10\/02\/1992/,/01\/02\/2001/p' input.txt

Read the rest of this entry…