Find all files larger than a certain size
find . -size +1000000k | xargs ls -lha {}
Move many many files to a new directory
find -maxdepth 1 -name ‘*.avi’ | xargs -i mv ‘{}’ Feb07/
Notes: ‘-maxdepth 1’ is to avoid find going on to find the files it’s just moved to a child directory
Copying properly a file system between partitions
tar clf - / | tar xvpf - -C /mnt/newdisk_root
Note -C does the old “cd to this directory” type stuff!!!
quick sed replacement
% sed 's/old/new/g' old.txt > new.txt
Quick VI replacement
:%s/old/new/g
Strip out email addresses from a raw text file
grep -o ‘[[:alpha:].]\+@[[:alpha:].]\+’
Find and replace some text in a load of files in a hierachical search
find . -name ‘*.bio’ | xargs perl -pi -e ‘s/PRODUCT\_…\_TM/…\_TM/g’
The above example was to find ‘PRODUCT_MIN_TM or PRODUCT_MAX_TM and replace with the same minus the PRODUCT (a PRIMER3 parameter).
quickly convert a load of single line sequences to a multi sequence Fasta file;
Insert a blank line after every other line
sed '/.*/G'
convert every blank line into a fasta header
sed 's/^$/\>/g'
Better version than the above
sed 'i\>seq'