Linux batch rename one-liner

Just in case I need it again and don’t remember: for f in <OLDPATTERN>; do mv “$f” “$(echo “$f” | sed ‘s/<OLDPATTERN>/<NEWPATTERN>/’)”; done And to batch-rename strings in all text-type files in a folder: for f in <FILEPATTERN>; do if [[ $(file “$f” | grep “text”) != “” ]]; then sed -i ‘s/<OLDPATTERN>/<NEWPATTERN>/g’ “$f”; fi;… Continue reading Linux batch rename one-liner

Using command timeouts inside of bash scripts

Sometimes one needs to terminate a command after a period of time and this particular command does not offer a timeout function itself. This could be a real show-stopper when it’s about running commands synchronously inside of scripts. Somehow I didn’t manage to get “timeout” from the coreutils working correctly inside of a bash script… Continue reading Using command timeouts inside of bash scripts