Linux commandline tips 4

From PvdMWiki
Jump to: navigation, search

watch if a website changes:

while :;do curl -Ls "X\.com"|md5sum;sleep 5m;done|awk '{if(NR>1&&l!=$1){system("echo the site changed|mail -s NOTIFY you@isp\.net");};l=$1}'

scan pdf to file. first extract the pages and ocr them, then make one doc

pdfimages -tiff input.pdf plaatje
for i in *.tif; do tesseract $i tempje-$i; done
cat tempje-plaatje-0*.txt >> docje.txt

ps ax -o state -o ppid | awk '$1=="Z"{print $2}' | xargs kill -9 # Kill all #zombies on the system.

ps aux |tail -n+2 |sort -nrk4 |head -$(($(tput lines)-1)) |cut -c 1-$(tput cols) # Display top RAM using processes.

ethtool -p eth0 # Blink eth0's LED so you can find it in the rat's next of server cables. Ctrl-C to stop.

find . -xdev -ls | sort -n -k 7 | tail -5 # Quickly find the largest 5 files in the CWD tree without crossing filesystem boundaries.

for f in *; do b=$(echo "$f" | tr '[A-Z]' '[a-z]'); mv "$f" "$b"; done # Lower case all files in a folder.

rpm -qf $( which lspci ) # Pass the output of which (showing path to lspci) into rpm's -qf, which tells you the pkg.

rename -v 's/^([0-9])_/0\1_/' *.flac # Rename all single leading digit flac files so that they have a padding 0 for easier sorting.

ps aux | awk '{if ($8=="Z") { print $2 }}'# On Linux, print out a list of the process IDs that are in the zombie state.

exiv2 -k -F rename *.jpg # Use the exiv2 EXIF program to rename your jpg files according to their exif date/time data.

curl http://wttr.in/castricum # see weatherforecast

finger amsterdam@graph.no

rpm -qa --queryformat "%{NAME} %{INSTALLTIME:date}\n" | grep "Nov 2015" # In RPM, determine which packages where installed in Nov 2015.

echo "wall \"hallo\""| at 11:48 2016-02-27 # execute a command at a certain time and date

ls -la "$(find . -type f -printf '%T@ %p\n' | sort -n | tail -1 | cut -f2- -d" ")" # show the most recent file in subtree

grep -Ev "((accept|drop|reject)log|ftpd)" /var/log/messages | less # Yes! You can do nested grouping in extended regexes.