1
score
|
Cut select pages from a pdf file and create a new file from those pages.$ pdftk input.pdf cat 2-4 7 9-10 output output.pdf |
1
score
|
Re-compress a gzip (.gz) file to a bzip2 (.bz2) file$ time gzip -cd file1.tar.gz 2>~/logfile.txt | pv -t -r -b -W -i 5 -B 8M | bzip2 > file1.tar.bz2 2>>~/logfile .txt |
1
score
|
Test your hard drive speed$ time (dd if=/dev/zero of=zerofile bs=1M count=500;sync);rm zerofile |
1
score
|
Recursively remove all empty sub-directories from a directory tree$ find . -depth -type d -empty -exec rmdir {} \; |
1
score
|
Group count sort a log file$ A=$(FILE=/var/log/myfile.log; cat $FILE | perl -p -e 's/.*,([A-Z]+)[\:\+].*/$1/g' | sort -u | while read LINE; do grep "$LINE" $FILE | wc -l | perl -p -e 's/[^0-9]+//g'; echo -e "\t$LINE"; done;);echo "$A"|sort -nr |
1
score
|
Use ghostscript to shrink PDF files$ gs -sDEVICE=pdfwrite -dCompatibilityLevel=1.4 -dPDFSETTINGS=/ebook -dNOPAUSE -dQUIET -dBATCH -sOutputFile=output.pdf input.pdf |
1
score
|
How to find all hard links to a file$ find /home -xdev -samefile file1 |
1
score
|
Find all the unique 4-letter words in a text$ cat ipsum.txt | perl -ne 'print map("$_\n", m/\w+/g);' | tr A-Z a-z | sort | uniq | awk 'length($1) == 4 {print}' |
1
score
|
Concatenate two or more movie files into one using mencoder$ mencoder cd1.avi cd2.avi -o movie.avi -ovc copy -oac copy |
1
score
|
Calculate the average execution time (of short running scripts) with awk$ for i in {1..10}; do time some_script.sh; done 2>&1 | grep ^real | sed -e s/.*m// | awk '{sum += $1} END {print sum / NR}' |
1
score
|
1
score
|
Rotate a movie file with mencoder$ mencoder video.avi -o rotated-right.avi -oac copy -ovc lavc -vf rotate=1 |
1
score
|
View specific column of data from a large file with long lines$ cat /tmp/log.data |colrm 1 155|colrm 60 300 |
1
score
|
Replace a regexp pattern in many files at once$ vi +'bufdo %s/pattern/replacement/g | update' +q $(grep -rl pattern /path/to/dir) |
0
score
|
Generate a sequence of numbers$ seq 1 10 |
0
score
|
Listen to a song from youtube$ listen-to-yt() { if [[ -z "$1" ]]; then echo "Enter a search string!"; else mpv "$(youtube-dl --default-search 'ytsearch1:' \"$1\" --get-url | tail -1)"; fi } |
0
score
|
Generate a sequence of numbers$ perl -e 'print "$_\n" for (1..10);' |
0
score
|
Find all of the distinct file extensions in a folder$ find . -type f | perl -ne 'print $1 if m/\.([^.\/]+)$/' | sort -u |
-1
score
|
Convert pip list --outdated for reuse in pip install -U$ pip install -U $(pip list --outdated 2> /dev/null | grep -v 'Version' | grep -v '------' | awk '{printf $1 " " }' && echo) |
-1
score
|
Delete all untagged Docker images$ docker rmi $(docker images -f "dangling=true" -q) |
-1
score
|
Get a free shell account on a community server$ sh <(curl hashbang.sh | gpg) |
-1
score
|
Run a local shell script on a remote server without copying it there$ ssh user@server bash < /path/to/local/script.sh |
0
score
|
Report disk usage by file type$ find . -type f -empty -prune -o -type f -printf "%s\t" -exec file --brief --mime-type '{}' \; | awk 'BEGIN {printf("%12s\t%12s\n","bytes","type")} {type=$2; a[type]+=$1} END {for (i in a) printf("%12u\t%12s\n", a[i], i)|"sort -nr"}' |
0
score
|
Find with invert match - e.g. find every file that is not mp3$ find . -name '*' -type f -not -path '*.mp3' |
0
score
|
Convert pip list --outdated for reuse in pip install -U$ python3 -m pip install -U $(python3 -m pip list outdated 2> /dev/null | grep -v 'Version' | grep -v '\-\-\-\-\-\-' | awk '{printf $1 " " }' && echo) |