Introduction You may sometimes need to run a script using cron which has dependencies on environment variables. Because cron runs non-interactively it will require a way to load those environment variables in at run time. Solution There are multiple ways
Useful bash Operations
Introduction A list of solutions for common problems working in a bash shell. Will update as I find them. Find two words existing on the same line https://stackoverflow.com/questions/6480687/grep-for-2-words-existing-on-the-same-line To grep for 2 words existing on the same line, simply do:
Linux Bash Printing Columns using AWK
Introduction If you ever had a requirement to parse huge firewall logs looking for something specific then trust me you will likely need to use awk possibly in combination with other commands such as grep, sort and uniq. Solution Get
Find and Change All Permissions Recursively
Introduction A couple of pretty simple bash commands for finding and changing permissions on all files and directories recursively. Obviously you need to understand what permissions you want in advance so check the man pages and online but for when
Bulk Replace Spaces in File Names
Introduction This is the easiest way I’ve found to replace spaces in file names with another character for example underscore. Solution At a bash prompt, use rename: find -name “* *” -type d | rename ‘s/ /_/g’ # do the
Bulk Rename File Extensions e.g. .JPG to .jpg
Introduction If you’ve ever needed to rename multiple files which had a different file extension then this is what you need Solution Open the terminal. Change directory to the parent directory of folder1 using the cd command. cd /path/to/parent/directory/of/folder1/ Run