Hi, I am new in scripting, and I am currently working on a script that will look for other files in a certain directory and exclude some file type.
this works fine:
but the excluded file to search [eg. *.out, *.dat] change from time to time so I have to change it into a variable. However, if I change my code into this..
it will give me this error:
I realize that the "! -iname" expression shouldn't be inside the string variable $exclude, but I need to concatenate other file to be exclude in the future, how can I make it work? Or is it still possible?
Thanks in advance.
this works fine:
Code:
Find_File2Exclude=`find ${paths[$k]} -maxdepth 1 -type f \( ! -iname '*.out' ! -iname '*.auc' ! -iname '*.cps' ! -iname '*.log' ! -iname '*.dat' \) -printf '%t %p\n' | sort -k 1 -n | head -n 1 | cut -d'/' -f3`
echo "other file searched == $Find_File2Exclude"
Code:
exclude=" ! -iname '*.out' ! -iname '*.log' ! -iname '*.cps' ! -iname '*.auc' ! -iname '*.dat'"
Find_File2Exclude=`find ${paths[$k]} -maxdepth 1 -type f \( $exclude \) -printf '%t %p\n' | sort -k 1 -n | head -n 1 | cut -d'/' -f3`
echo "$Find_File2Exclude"
Quote:
find: paths must precede expression Usage: find [-H] [-L] [-P] [path...] [expression] |
Thanks in advance.