Simple bash if then else example

if [ -r somefile ]; then 
   content=$(cat somefile) 
elif [ -f somefile ]; then 
   echo "The file 'somefile' exists but is not readable to the script." 
   echo "The file 'somefile' does not exist." 

Justin Kelly

Justin Kelly

Data Engineeer, Business Analytics, Web Developer, Library Technology specialising in PHP and Tableau

Based in Melbourne, Australia

Feel free to contact me or _justin_kelly