Skip to navigation

Archive for the 'Bash shell' Category

Mutt: set dynamic email signature from shell command output

Saturday, October 3rd, 2009

I want to set my signature when mailing to the r-help mailing list to contain information about the R version I have currently installed. Creating a bash script that directly echoes the several lines that I want to have in my signature and executing that in the muttrc using backticks gives a “broken pipe” error. [...]

How to use mutt to send individual e-mails to lots of people at once

Wednesday, March 18th, 2009

So, you want to send an e-mail to a list of people, but you don’t want to put them all in the “To:” or the “Bcc:” field of a single mail. You want each person to get an individual e-mail, but with the same subject line and the same content. It’s easy using mutt. Create [...]

Filename pattern matching via bash extended globbing and find regular expressions in shell scripts

Tuesday, January 20th, 2009

I was confused that bash would expand some patterns nicely to match filenames when I was on the commandline, but the same pattern would not work from inside a shell script. For example, the following pattern would nicely match all files in the current directory not having an “Rnw” or “tex” extension on the commandline: [...]

Removing duplicate lines from a file

Wednesday, January 14th, 2009

Case-insensitive: { rm “$file” && awk ‘!x[tolower($1)]++’ > “$file”; } < "$file" Case-sensitive: { rm "$file" && awk '!x[$1]++' > “$file”; } < “$file” Here’s a shell script you could use, as it stands, only works for one file at a time: #!/bin/bash usage() { cat “$filename”; } < “$filename” else { rm “$filename” && [...]

SD card with ReiserFS for backups

Thursday, May 15th, 2008

The hard drive on my laptop has occasionally been making some funny klicking noises recently, and I’m a bit worried it’s going to break down one of these days. So in addition to backups to an external HD and a USB stick, I bought a 4 GB SD card to just leave in the card [...]