1 Liners

Print all primes less than 5000:

$ python3 -c 'print([i for i in range(2,5000) if all(i%j for j in range(2,int(i**0.5)+1))])'

Break a GIF into individual frames:

ffmpeg -i taarna.gif frame_%d.jpg

List all the words in a file with no matches in the dictionary:

aspell list < huckfinn.txt

Play a G major chord on ‘guitar’ using the sox package:

play -n synth pl G2 pl B2 pl D3 pl G3 pl D4 pl G4 delay 0 .05 .1 .15 .2 .25 remix - fade 0 4 .1 norm -1

Convert a PDF file to JPEG:

pdftocairo path/to/file.pdf -jpeg

Tally a column of figures in awk:

awk '{sum += $3} END {print "Total:", sum}' tribes

Tell Python to recite the powers of two in English

seq 1 16|while read n;do echo $((2**n));done|python3 -c "import sys,inflect;p=inflect.engine();[print(p.number_to_words(int(x.strip()))) for x in sys.stdin if x.strip()]"

Extract pages from a PDF file:

gs -sDEVICE=pdfwrite -dNOPAUSE -dBATCH -dSAFER -dFirstPage=34 -dLastPage=34 -sOutputFile=test2.pdf The-Cambridge-Handbook-of-Physics-Formulas.pdf

Display an image without a border:

feh --borderless /home/teresita/Downloads/48773.jpg &

Batch convert HTML to text:

for i in *.html; do lynx --dump "$i" > "${i%%.*}.txt";done

Build a list of words from a file:

cat gettysburg.txt | tr ' ' '\012'|tr '[A-Z]' '[a-z]' |sed "s/punct://g" |sort|uniq

Sort the Holy Bible by verse length with Perl:

perl -e 'print sort {length $b <=> length $a} <>' kjv.txt

Batch convert HTML to text:

for i in *.html; do lynx --dump "$i" > "${i%%.*}.txt";done

Use awk to print a count of words ending by letter:

awk 'length > 1{++a[substr(tolower($0), length)]}END{for (k in a) print a[k], k}' words.big | sort -n

Grab a stretch of unicode while inside #vim

:py3 import vim;vim.current.buffer.append(" ".join(chr(i) for i in range(945,970)))

Get a weather forecast at the console:

curl -s -L https curl wttr.in/seattle

Shuffle and rename the files in a directory of images

echo '#!/bin/bash' > files; chmod 744 files; ls -1 | shuf | nl -i1 -s' ' -nrz -w5 | awk '{print "mv " $2 " " $1 ".jpg"}' >> files ; ./files

Build thumbnails with the same basename from a directory of video files using ffmpegthumbnailer and bash:

for oldfile in *.mp4; do filename="${oldfile%.*}"; ffmpegthumbnailer -i "$filename.mp4" -o "$filename.jpg"; done

Calculate parallel resistance (or series capacitance) for any number of discrete components with Python

python3 -c "import sys; print(f'{1/sum(1/float(x) for x in sys.argv[1:]):.2f}')" 1800 2700 3300

 

 

 

 

 

 

Unknown's avatar

About Linuxgal

Need a spiritual home? Consider joining us at Mary Queen of the Universe Latter-day Buddhislamic Free Will Christian UFO Synagogue of Vishnu
This entry was posted in Uncategorized. Bookmark the permalink.

Leave a comment