| | |
Using find in a bash shell script
Thread Solved |
•
•
Join Date: Dec 2004
Posts: 9
Reputation:
Solved Threads: 0
I recently ran the following command from the command line and it worked
find . -name '*jrAPS*_ouput.log' -exec grep '<string expression>' {}\; -print
I put it in a shell script like this and it did not work
find . -name \'*jrAPS*_output.log\' -exec grep \'<string expression>\' {} \\\; -print
the result was find: incomplete statement why?
find . -name '*jrAPS*_ouput.log' -exec grep '<string expression>' {}\; -print
I put it in a shell script like this and it did not work
find . -name \'*jrAPS*_output.log\' -exec grep \'<string expression>\' {} \\\; -print
the result was find: incomplete statement why?
•
•
Join Date: Dec 2004
Posts: 2
Reputation:
Solved Threads: 1
On my system, I don't need to perform all the escaping that you are doing. The same command that I use on the command line works in the shell script because nothing is interpreting the command before executing it. However, if you have another shell reading commands from this script and executing them, then you would need the escapes. If that doesn't help use bash -n $0 where $0 is your current command line to see if you have syntax errors before running. Sometimes the error messages are slightly different (or more of them) when just analyzing.
•
•
Join Date: Dec 2004
Posts: 2
Reputation:
Solved Threads: 1
Sorry, I don't know of any public Linux Servers.
If you need an easy install try Xandros Open Edition. You answer 5 or 10 questions, wait about 30 minutes and voila instant Linux - with sound and networking. http://www.xandros.com
If you need an easy install try Xandros Open Edition. You answer 5 or 10 questions, wait about 30 minutes and voila instant Linux - with sound and networking. http://www.xandros.com
•
•
Join Date: Dec 2004
Posts: 9
Reputation:
Solved Threads: 0
Here is the shell script I am trying to run in bash
if [ $# -neq 1 ];
then
echo "Usage: <program name> <string expression>"
exit 1
fi
findstr=$1
echo "$findstr"
find . -name 'm1_jrAPS*_output.log' -exec grep \'"$findstr"\' {} \; -print
In the above script I want to take the string from the command line and put it in the find command in the shell script I have a hard time getting the shell to expand it in single quotes like in the regular command
if [ $# -neq 1 ];
then
echo "Usage: <program name> <string expression>"
exit 1
fi
findstr=$1
echo "$findstr"
find . -name 'm1_jrAPS*_output.log' -exec grep \'"$findstr"\' {} \; -print
In the above script I want to take the string from the command line and put it in the find command in the shell script I have a hard time getting the shell to expand it in single quotes like in the regular command
![]() |
Similar Threads
- Sending email from a shell script (Shell Scripting)
- load-intensive shell script (Shell Scripting)
- Need help in Shell script (Shell Scripting)
- exiting the shell within a shell script (Shell Scripting)
Other Threads in the Shell Scripting Forum
- Previous Thread: Subshell Problem, syntax error...Help please!
- Next Thread: GC Tags file for a large project
| Thread Tools | Search this Thread |







