If I have a BASH variable:
Exclude='somefile.txt anotherfile.txt'
How can I get the contents of a directory but exclude the above to files in the listing? I want to be able to do something like:
Files= #some command here someprogram ${Files}
someprogram should be given all of the files in a particular directory, except for those in the ${Exclude} variable. Modifying someprogram is not an option.
I’m not sure if you were taking about unix shell scripting, but here’s a working example for bash:
Note that I enclosed every filename in Exclude with double quotes and added parenthesis around them. Replace
echowithsomeprogram, change the ls command to the directory you’d like examined and you should have it working. Thecommprogram is the key, here.