Find file with specific content

find . -type f -name '*.R' -exec grep -l "pattern"  {} \;

similar to:

find folder -type f -name '*.R' | xargs  grep "pattern"

start_time=$(date -R)    
set -e

[...]

echo "*** DONE"
end_time=$(date -R)    
echo $start_time
echo $end_time
exit 0

Execute a function before exiting the script

function mvBack {
  echo "... go back to my folder"
  cd $runDir  
}
trap mvBack EXIT

Move file in for-loop

for file in *.jpg ; do mv $file ${file//IMG/myVacation} ; done

Interpolate between number range for for-loop

for chromo in ( "chr"{1..22} ); do echo $chromo; done

Read line by line from file

cat ./SAMPLES.txt| while read SAMPLE
do
    mkdir ${OUTDIR}/${SAMPLE}
done

Copy to new file with substituted file name

cp top-words-{1,2}.sh # copy 1 to 2

Space usage by disks:

df -h

Space usage for a given folder:

du -sh FOLDER_NAME