shell scripts
recursive sed excluding svn files
replace string1 with string2, recursively:
find ./ -path '*/.svn' -prune -o -type f -exec sed -i "s/string1/string2/g" {} \;batch converting Nikon .NEF images to greyscale JPG
Run this in a directory of .NEF files to
* create a directory "mkdir bw-jpg-greyscale-lightness"
* convert each image to black and white with auto exposure, colors, white-balence, etc.
* save each image as a JPG to the "mkdir bw-jpg-greyscale-lightness" directory
Written by yours truly
#!/bin/sh
mkdir bw-jpg-greyscale-lightness;
for file in *.NEF;
do ufraw-batch $file --out-path=bw-jpg-greyscale-lightness --wb=auto --exposure=auto --black-point=auto --color-smoothing --grayscale=lightness --out-type=jpg;
donelinux tar simple example
OK, this is really simple, but I'm always forgetting the exact syntax, and man pages are overkill for this.
Tar a directory "dir" into a gzip'd tarball:
tar -zcvf dir.tar.gz dirAnd extract it:
tar -zxvf dir.tar.gzsimple sed example
This will globally find and replace all instances of "find" with "replace"
$ sed -i 's/find/replace/g' file.txtUbuntu lucid: downgrading to php 5.2
I'm attaching the shell script I used to do this...Slightly modified from other variations online. Obviously don't run this without understanding it- it will remove your existing php packages
Then if you need to install any additional php packages, just install them with ( notice the -t karmic option )
sudo aptitude install -t karmic php5-mysql php5-xdebug phpmyadminFor more info:
http://jtrancas.wordpress.com/2010/05/04/cakephp-1-1-and-php-5-3/
http://ubuntuforums.org/showthread.php?t=1459163&page=2
adding aliases the easy way
I'm always forgetting the syntax..
echo "alias drush='~/drush/drush'" >> ~/.bash_profile
source ~/.bash_profileGREP sans SVN
Here's a quickie to do a recursive grep, ignoring SVN files:
grep --exclude=\*.svn\* -r "my_string_here" .Curl your Drupal modules
Why bother to download, unzip, and stick in your modules dir?
Just cd sites/all/modules and do this:
curl http://ftp.drupal.org/files/projects/tinytax-6.x-1.11.tar.gz|tar -xzf -and replace "tinytax-6.x-1.11" with whatever the module is, obviously...
OR - if you're feeling really slick - use drush, then just run php-cli path/to/drush/drush.php pm install module_name
Removing all .svn directories
HOWTO Recursively remove all svn directories from a directory... yay I love shell scripting. BE CAREFUL WITH THIS!!
find . -type d -name ".svn" -exec rm -rf {} \;Ubuntu - convert a directory of .wav's to .mp3's
Here's a quickie shell script to convert .wav files to .mp3's:
cd to the directory, save this as convert.sh, then do chmod a+x convert.sh, then run it with ./convert.sh
#!/bin/sh
# convert all .wav's to .mp3's and remove the .wav from the resulting filename
for f in *.wav ; do lame -V2 $f ; done;
for f in *.mp3 ; do AUFILE=`echo "$f" | sed 's/.wav//g'` ; mv "$f" "$AUFILE"; doneIf you want to remove all the .wav files just do rm -rf *.wav ...but be careful :)