ambiguous redirection question.
Guys,
I have a simple question. I am doing two "finds" and first one works fine without any question however for the second one I am getting error like "ambiguous redirect" . Well this is becoming an interesting thing as the syntax is fine and don't think there is any issue with that. First find statement. Code:
find ${BASE_DIRECTORY} -path \*/input/* -type f -not -wholename "*/unused/*" -mmin +60 -print >> ${INPUT_FILES} Code:
find ${BASE_DIRECTORY} -path \*/error/* -type f -not -name "SS*" -not -name "AA*" -not -name "PQ*" -mmin +60 -print >> ${ERR0R_FILES} |
Try saying the second one out loud ... I think you will find there is a word missing between each 'not name' combo.
I would also be curious why you want the first asterisk not interpreted but then leave the second raw for the -path argument?? |
I used 2>&1 | tee -a ${LOGFILE} and error disappeared. I don't think there is any word missing between "-not -name "AA*
as I believe that is what the syntax is? Moreover If I run the same command in shell it works fine except in shellscript. I could not understand your second question. Quote:
|
I now understood your second question. For path, all I want is all is all those files which match following pattern.
Code:
h1/input/h2 |
Adding quotes around the variable seems to be a good way to deal with the "ambiguous redirect" message: You tend to get a better message when you've made a typing mistake -- and when the error is due to spaces in the filename, using quotes is the fix.
Code:
bash-4.2$ find ${BASE_DIRECTORY} -path \*/error/* -type f -not -name "SS*" -not -name "AA*" -not -name "PQ*" -mmin +60 -print >> "${ERR0R_FILES}" |
Quote:
Code:
... -path \*/error/* ... Code:
... -path \*/error/\* ... Quote:
However, once invoke command without redirecting it's output to a file, and check where you're getting error: Code:
~$ find ${BASE_DIRECTORY} -path \*/error/* -type f -not -name "SS*" -not -name "AA*" -not -name "PQ*" -mmin +60 -print |
Check if ${ERR0R_FILES} exists and else first create it. The find command works fine here.
|
Quote:
@OP: Can you once try following, without closing variable name in curly braces, as follow: Code:
find $BASE_DIRECTORY -path \*/error/* -type f -not -name "SS*" -not -name "AA*" -not -name "PQ*" -mmin +60 -print >> $ERR0R_FILES |
My bad on my first point ... it just seemed there should be some and's or or's in between the not's. I am guessing this is somehow implied as an and in this case.
And yes shivaa pointed out my curious question correctly. Personally I would have just used single quotes as escaping gives me the yips. |
As was suggested by whizje, the "ambiguous redirect" error is very likely due to the unquoted variable ERROR_FILES containing embedded white space in its value. I can easily reproduce the behavior that way:
Code:
$ ERROR_FILES="bad files" |
Quote:
|
@grail
I don't think so there is anything missing between -not -name "PQRS*" I believe this is the syntax, anything wrong here? |
@whizje
I did try " around the variable name but that didn't worked not sure why. |
@shivaa
Why you suggest the original quote without curly brace? normally we use variable in dollar with curly braces right? Please advise. Thanks. |
@shivaa
Quote:
Code:
2>&1 | tee -a ${LOG_FILE} |
All times are GMT -5. The time now is 04:50 PM. |