bash cp exclude files code example

Example 1: bash ls exclude file

# Note: there isn't an ls command specifically, BUT:
# you could use the 'find' command instead

# syntax ("!" is the entry for not)
find *</path/to/folder> ! -name '*<substring to exclude>'

# example
find /jacquesk/home/RandomFiles ! -name '*ExcludeFile*.txt'

# This will list all the files in the current directory 
# of "/jacquesk/home/RandomFiles" that does NOT contain 
# "ExcludeFile" (anywhere in the string) AND do not end in ".txt"

Example 2: cp exclude file

rsync -av --progress sourcefolder /destinationfolder --exclude thefoldertoexclude