2
score
|
Get mac address from default interface OS X$ netstat -rn | awk '/default/ { print $NF }' | head -1 | xargs -I {} ifconfig {} | awk '/ether/ {print $2}' |
5
score
|
Convert directory of videos to MP4 in parallel$ for INPUT in *.avi ; do echo "${INPUT%.avi}" ; done | xargs -i -P9 HandBrakeCLI -i "{}".avi -o "{}".mp4 |
1
score
|
Create a transparent image of given dimensions$ convert -size 100x100 xc:none transparency.png |
1
score
|
Print a random cat$ wget -O - http://placekitten.com/$[500 + RANDOM % 500] | lp |
0
score
|
Create a heap dump of a Java process$ jmap -dump:format=b,file=/var/tmp/dump.hprof 1234 |
0
score
|
Insert lines from one text file to another one$ awk 'NR % 10 == 1 {getline f2 < "file1"; print f2} 1' file2 | cat -n |
0
score
|
Insert lines from one text file to another one$ sed -re ':a;Rfile1' -e 'x;s/^/./;/.{10}/!{x;ba};s/.*//;x' file2 |
0
score
|
Check that a directory is a parent of another$ is_parent() { [[ "$2" =~ $1/? ]]; } |
0
score
|
Create fattal tone mapped images from a directory of raw images$ for img in /path/to/rawimages/*.RW2; do pfsin ${img} | pfssize -x 1024 -y 768 | pfstmo_fattal02 -v -s 1 | pfsout /path/to/finished/${img%%}.jpg; done |
0
score
|
Send a file by email as attachment$ uuencode /var/log/messages messages.txt | mailx -s "/var/log/messages on $HOST" me@example.com |
0
score
|
Calculate md5sum from an input string$ md5sum <<< YOUR_TEXT | cut -f1 -d' ' |
2
score
|
Convert a music file (mp3) to a mp4 video with a static image$ ffmpeg -loop_input -i cover.jpg -i soundtrack.mp3 -shortest -acodec copy output_video.mp4 |
1
score
|
Find all of the distinct file extensions in a folder$ find . -type f | perl -ne 'print $1 if m/\.([^.\/]+)$/' | sort -u |
2
score
|
Dump network traffic with tcpdump to file with time-stamp in its filename$ date +"%Y-%m-%d_%H-%M-%Z" | xargs -I {} bash -c "sudo tcpdump -nq -s 0 -i eth0 -w ./dump-{}.pcap" |
0
score
|
Get streamed FLV from Chrome with lsof$ export psid=$(pgrep -f libflashplayer.so); cp /proc/$psid/fd/$(lsof -p $psid | grep eleted | awk {' print $4 '} | sed -e "s/[a-z]//g") saved.flv |
2
score
|
Remove files and directories whose name is a timestamp older than a certain time$ ls | grep '....-..-..-......' | xargs -I {} bash -c "[[ x{} < x$(date -d '3 days ago' +%Y-%m-%d-%H%M%S) ]] && rm -rfv {}" |
4
score
|
Tree-like output in ls$ ls -R | grep ":$" | sed -e 's/:$//' -e 's/[^-][^\/]*\//--/g' -e 's/^/ /' -e 's/-/|/' |
1
score
|
Unhide all hidden files in the current directory.$ find . -maxdepth 1 -type f -name '\.*' | sed -e 's,^\./\.,,' | sort | xargs -iname mv .name name |
0
score
|
Rename all files in a directory to upper case$ for i in *; do mv "$i" "${i^^}"; done |
5
score
|
Rename all items in a directory to lower case$ for i in *; do mv "$i" "${i,,}"; done |
0
score
|
Print file owners and permissions of a directory tree$ find /path/to/dir1 -printf "%U %G %m %p\n" > /tmp/dir1.txt |
1
score
|
Get only the latest version of a file from across mutiple directories.$ find . -name 'filename' | xargs -r ls -tc | head -n1 |
1
score
|
Sort and remove duplicate lines from two (or more files). Display only uniq lines from files.$ sort file1 file2 | uniq -u |
0
score
|
Get only the latest version of a file from across mutiple directories$ find . -name custlist\* | perl -ne '$path = $_; s?.*/??; $name = $_; $map{$name} = $path; ++$c; END { print $map{(sort(keys(%map)))[$c-1]} }' |
2
score
|
Create a thumbnail from the first page of a PDF file$ convert -thumbnail x80 file.pdf[0] thumb.png |