Find in Bash with -a option


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Find in Bash with -a option
# 1  
Old 05-13-2010
Data Find in Bash with -a option

Hi,

The proble is below:
Assume i have files starting from "process" then date/time then ".log".
ex .
Code:
process.20100504092942.log
process.20100503152213.log
process.20100430144217.log
process.20100429153644.log
process.20100428121200.log
process.20100427130746.log
process.20100427130350.log
process.20100427070336.log
process.20100427065534.log
process.20100427063908.log
process.20100426122504.log

I run below find statement at command prompt -
Code:
find . \( -name "process*" -a -name "*20100427*" \) -exec ls {} \;

and get the result -
Code:
process.20100427130746.log
process.20100427130350.log
process.20100427070336.log
process.20100427065534.log
process.20100427063908.log

But once I run the same command in on shell .sh file -

got the error -
Code:
find: paths must precede expression
Usage: find [path...] [expression]

It seems it is not able to interpret the \( properly. I gave \\\( i.e \\ + \( to become \( but not resolved.
Could anyone help on this.
Thanks,
Vipin.

Last edited by Franklin52; 05-13-2010 at 02:02 PM.. Reason: Please use code tags, thank you
meetvipin
# 2  
Old 05-13-2010
Have you tried using the bash shell for your script? Put this on the first line of your script:

Code:
/bin/bash

Please post the output.
# 3  
Old 05-14-2010
I mentioned that i am using BASH.
I found th problem, I was not giving the double quotes for the string -

find . \( -name "${PROCESS_NAME}*" -a -name "*${File_Date}*" \) -print

Now it's working.
thanks.
meetvipin
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Bash read with -p option

I have this simple code to stop script execution. I did not invent it, and it works. It used to have fackEnterKey as option, but it works without it. My curiosity question is - the "function " terminates when "enter" key is pressed and only "enter" key. I did read the man and... (5 Replies)
Discussion started by: annacreek
5 Replies

2. Shell Programming and Scripting

Menu Driven Bash Shell Script with Default Option

Hi All, I have written a menu driven bash shell script. Current Output is as below: ------------------------------------- Main Menu ------------------------------------- Option 1 Option 2 Option 3 Option 4 Exit ===================================== Enter your... (3 Replies)
Discussion started by: kiran_j
3 Replies

3. UNIX for Dummies Questions & Answers

find with mtime option

Hi, Please give me more details on the following examples, about "mtime" option. When I try this, I could not get the expected output, please help. find . -mtime -1 -print find . -mtime +1 -print find . -mtime 1 -print How do I get the files modified between two dates, say from... (4 Replies)
Discussion started by: Dev_Dev
4 Replies

4. Shell Programming and Scripting

Bash Script for parse input like option and value

I would create a bash script than parse like this: test.sh -p (protocol) -i (address) -d (directory) I need retrive the value after -p for example... understand??? I hope... thanks (6 Replies)
Discussion started by: ionral
6 Replies

5. Shell Programming and Scripting

find -regex option

I'm trying to use regular expression arguments as variables. I have to surround the regular expression with double quotes or else it automatically expands that regular expression to whatever is in that directory. Unfortunately when I run 'find' it further surrounds the double quotes with single... (6 Replies)
Discussion started by: stevensw
6 Replies

6. Shell Programming and Scripting

Help with find -perm option

How to find all files for instance that match the permission rwxr*x--- where * is a wildcard which can be optionally asserted but all the others must match? Thanks in advance (7 Replies)
Discussion started by: stevensw
7 Replies

7. Shell Programming and Scripting

recently introduced to the newer option for find...does an older option exist?

To find all the files in your home directory that have been edited in some way since the last tar file, use this command: find . -newer backup.tar.gz Is anyone familiar with an older solution? looking to identify files older then 15mins across several directories. thanks, manny (2 Replies)
Discussion started by: mr_manny
2 Replies

8. Shell Programming and Scripting

help with find command and prune option

Hi I have a directory say mydir and inside it there are many files and subdirectories and also a directory called lost+found owned by root user I want to print all files directories and subdirectorres from my directory using find command except lost+found If i do find . \( -name... (3 Replies)
Discussion started by: xiamin
3 Replies

9. Shell Programming and Scripting

find with prune option

Hi, I want to list files only from the current dir and its child dir (not from child's child dir). i have the following files, ./ABC/1.log ./ABC/2.log ./ABC/ABC1/A.log ./ABC/ABC1/B.log ./ABC/ABC1/XYZ/A1.log ./ABC/ABC1/XYZ/A2.log Here i want to list only the log file from current... (1 Reply)
Discussion started by: apsprabhu
1 Replies

10. UNIX for Dummies Questions & Answers

Find and EXECDIR option

Hello, I was reading the man pages of find and it says that the -exec option should not be used. I read the following about the recommended option, -execdir: -execdir command {} + Like -exec, but the specified command is run from the subdirec‐ tory containing... (1 Reply)
Discussion started by: mojoman
1 Replies
Login or Register to Ask a Question