Remove all newlines
cat file.txt | tr -d '\n' > newfile.txt
Chop the last character of a file
head -c -1 file.txt
From line i to j of file
sed -n 'i,j p' file.txt >
From line m to end of file
tail +m file.txt
sed -n 'm,$p' file.txt >
Exec'ing a command with find
find . -name "pattern" -exec cmd {} \;
Size of a file without using ls
stat -s "%s %N" file.txt
Rename file extensions using sh and sed
ls *.mp3 | sed 's/\(.\)\.mp3/mv "\1.mp3" "\1.m4a"/' | sh
Back to back tar via ssh
tar cf - files | ssh "(cd /home/gord/tmp; tar xf -)"
Comparing two binary files byte by byte
cmp -lb file1 file2
Adding up a text file containing numbers
cat file.txt | awk '{total+=$0}END{print total}'
Parallel processing using xargs
ls *.txt | xargs -n1 -p4
String splitting using awk
awk 'BEGIN{FS="\n"}; { split($1, a, "foobar="); split(a[2], b, "\""); print b[2]; }'
Almost flattening an xml file
cat foobar.xml | tr '\n' ' ' | sed "s/ \( \)\+/ /g" | sed "s/<\\/closingElementTag> /\n/g
Coin Counting in Scala
def countChange(m: Int, cs: List[Int]): Int = cs match {
  case Nil => if(m == 0) 1 else 0
  case c::rs => (0 to m/c) map (k => countChange(m-k*c,rs)) sum