Take a remote screenshot

ssh user@remote-host “DISPLAY=:0.0 import -window root -format png -“|display -format png –


How to remove annoying tags from every srt subtitle file

Sites like opensubtitles.org have the annoying habit of tagging their files with subtitles like “Tip for download: Open Subtitles MKV Player” and “Downloaded from http://www.opensubtitles.org”.

Here is a fast single command to get rid of all that on all subrip (.srt) files, using find, sed, and a bit of regex:

find . -name \*.srt -execdir sed -i '/pen.*ubtitles/d' {} +

I did it for dozens of files in one command ;)

find” searches all subdirectories below the current one (.) for every file with the srt extension (-name \*.srt) and executes the sed command that deletes on those files ({} +) the lines matching the regex pattern (pen.*ubtitles).


Run a bash script or command using multiple input files

Here is how to run a bash script using a set of files in succession  as input:

for i in $( ls_to_select_input_files ) ; do your_scriptname_or_command $i ;done

For example,
The following command:

for i in $( ls *.inp ) ; do obchiral $i |grep Clockwise;done

will get all *.inp GAMESS input files in the directory and check the chirality of all chiral atoms with obchiral (from openbabel).