Archive for the ‘Utilities’ Category.

Grep text in PDF’s using pdftotext

If you ever need to grep some specific tags in a bunch of pdf files, you can use the following one liner, e.g:

for FILE in $(find /home/user/Desktop/downloads/ -name "*.pdf" 2>/dev/null -mtime -1 \! -type d -exec ls {} \;); do pdftotext $FILE - | grep -o 'BZ [0-9]\{5\}';done

Encrypt/Decrypt a file using openssl

Encrypt the file:
openssl des3 -salt -in file.txt -out encrypted_file.txt

Decrypt the file:

openssl des3 -d -salt -in encrypted_file.txt -out decrypted_file.txt

Last.fm from the command line

If you are a command line addict, you can download shell-fm and start listening Last.fm from there.

Links to customize it:
http://jdin.blogspot.com
http://shell-fm.wikidot.com/extending-shell-fm

Fsniper

fsniper allow to monitor your folders and trigger some actions based on the type of files you have there.

Example: ~/.config/fsniper/config
PDF files downloaded from Firefox on the desktop, get moved to ~/Desktop/pdf.

watch {
~/Desktop {
*.part {
handler = echo ignoring file: %%
}
application/pdf {

handler = mv %% ~/Desktop/pdf
}
}
}

Fsniper can be run in daemon mode:

fsniper --daemon

Check process using strace

strace -f -r -o pid.out -p {PID}