Find statement


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Find statement
# 1  
Old 01-26-2009
Find statement

for FNAME in `find /unixs/apps/sqr/ -type f -exec grep -il unixs {} \;`; do C=`grep -c unixs ${FNAME}`; echo "${C}:${FNAME}" >> /unixs/apps/cibcur01.txt; done

I have this statement but I only want to look for my string in file types .sql, .KSH,.sh files. How can I accomplish this?
# 2  
Old 01-26-2009
try this:
Code:
F=`find /unixs/apps/sqr/ -type f \( -name '*.KSH' -o -name '*.sh' -o -name '*.sql' \) \ 
    -exec grep -il unixs {} \;`

for FNAME in $F 
do 
   C=`grep -c unixs ${FNAME}`
   echo "${C}:${FNAME}" 
done > /unixs/apps/cibcur01.txt

# 3  
Old 01-26-2009
find not working

for FNAME in `find /unixs/interface/erp07u -type f \( -name '*.KSH' -o -name '*.sh' -o -name '*.sql' -o -name '*.ksh ' \) -exec grep -il unixs{} \;`; do C=`grep -c unixs ${FNAME}`; echo "${C}:${FNAME}" >> /unixs/apps/unixseu.txt; done

This return file with extension *.log as well.
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

0403-016 Cannot find or open the file in If Statement

Hi, I am comparing the number of records in the .bad record from sql loader, if it is higher than the number passed in as an argument, the program should exit. However, I constantly receive the error " 0403-016 Cannot find or open the file." on the line with the if statement "elif ;". The code... (3 Replies)
Discussion started by: MIA651
3 Replies

2. UNIX for Dummies Questions & Answers

Multiple Find Conditions in IF Statement - UNIX

When I try the below if Condition with single condition its working fine. But when I try to Club both its working . But giving wrong results. In my case cond1 = -f ${filename1} = true cond2 = -f ${filename2} = true But Cond1 & Cond2 is resulting in False ??? Please advise ... (5 Replies)
Discussion started by: Shiny_Reddy
5 Replies

3. UNIX for Dummies Questions & Answers

Statement to find if an entry exists in a file

I need to check if an entry input by the user is in a file. If so, I need to run a command, and if it does not exist then it should output entry does not exist. So I have so far... echo "Enter record:" read record //command || //command Can I use an if statement to do this? (3 Replies)
Discussion started by: itech4814
3 Replies

4. Shell Programming and Scripting

trying to find match from multiple string if statement

I'm trying to create what (should be) a simple bash script that will pull computer name and use that info to bind to one of three servers. Is there any way to do this without having a text file with the names of the servers and associated computer names? (5 Replies)
Discussion started by: jacobsbigbro1
5 Replies

5. Shell Programming and Scripting

Problems with find | ls within a for statement

Hello, for dir in `find /root/test -type d` ;do echo "$dir" done for dir in `ls -1d /root/test/*/` ;do echo "$dir" done If there's a directory with spaces in name, it does echo each word of that dir separately... solution? mkdir "test" cd test mkdir "example_1_2_3"... (6 Replies)
Discussion started by: TehOne
6 Replies

6. Shell Programming and Scripting

awk statement to find events from a specific date

I have a script which archives log file events which are 90-days old. Script works fine but I wanted some input on one aspect of this script. My nawk statement, bolded below, that removes events 90-days prior from today, I need it to find anything 90-days or older. The log file date pattern looks... (0 Replies)
Discussion started by: numele
0 Replies

7. UNIX for Dummies Questions & Answers

echo statement when find returns null

Hi, How do you echo something once when a find statement returns null results? This is when using mutiple locations and mutiple arguments. The below find command the inner loop of a nested for loop where the outter loop holds the $args and the inner loop holds the locations. find... (2 Replies)
Discussion started by: tchoruma
2 Replies

8. Shell Programming and Scripting

For loop find statement file name manipulation

for i in `find . -name "*.BEFORE_DISASTER_RECOVERY"`;do dir_name=`dirname $i`;file_name=`basename $i`;cd $dir_name;mv $file_name (STUCK HERE) ;pwd;cd $BASE_DIR;done Okay, so I was able to get to this point. As you can see, I have a small for loop that searches for any files with the string... (5 Replies)
Discussion started by: cbo0485
5 Replies

9. Shell Programming and Scripting

whats wrong with this find statement ?

cmd="find /a/technologies -name '*.jar' | grep \"Tuning/specificloader/lib\"" echo $cmd for index in `$cmd` do SL_JARS="${SL_JARS}:${index}" done gives error ==> find: paths must precede expression Usage: find but for index in... (2 Replies)
Discussion started by: crackthehit007
2 Replies

10. Shell Programming and Scripting

find/if statement not working

Hi guys: I am trying to delete multiple files in a folder with different names. Below is the script that I was trying, but it doesn't work ************************** #!/bin/ksh DATE=`date '+20%y%m%d'` DEL_DIR=<dir where files have to be deleted> let DATE2=$(($DATE - 2)) let DATE1=$(($DATE... (12 Replies)
Discussion started by: geomonap
12 Replies
Login or Register to Ask a Question