Sponsored Content
Full Discussion: complex find in script
Top Forums Shell Programming and Scripting complex find in script Post 302280562 by methyl on Tuesday 27th of January 2009 08:55:24 AM
Old 01-27-2009
I agree. The missing pipe is part of the problem.
Rearranging the original commands without introducing new syntax.
(We don't know which shell is in use here).
If we used "grep -il" to find the files , we must use "grep -ic" to count the contents.
Full stops in strings need quoting (or the whole string in single quotes) to prevent the full stop becoming part of a regular expression.


Code:
find /unixsxxx/interface/x.x/xxxxxx -type f \( -name '*.KSH' -o -name '*.sh' -o -name '*.sql' -o -name '*.ksh' \) -print | while read FNAME
do
        # Find any files which contain xxx.xxx.xxx.xxx
        grep -il 'xxx.xxx.xxx.xxx' "${FNAME}" | while read FOUND
        do
                # Count occurances in selected file
                C=`grep -ic 'xxx.xxx.xxx.xxx' "${FOUND}"`
                echo "${C}:${FOUND}" >> /unixs317/apps/output.txt
        done
done


Last edited by methyl; 01-27-2009 at 10:04 AM.. Reason: typos
 

10 More Discussions You Might Find Interesting

1. Answers to Frequently Asked Questions

advanced/complex uses of the find command

Perhaps the number one advanced find question is: How to stop find from descending into subdirectories? find command Performing a non-recursive find in Unix Use -prune with find command on AIX Searching for files over 30 days old in current directory disk space used for files with in a... (0 Replies)
Discussion started by: Perderabo
0 Replies

2. Shell Programming and Scripting

Complex find grep or sed command

Haven't worked in bash for ages. did a good bit of shell scripting in regular sh, but have forgotten most of it. I have several thousand php files that now include the following line at the end of the file. There is no LF or CR/LF before it begins, it is just concatenated to the final line of... (3 Replies)
Discussion started by: sjburden
3 Replies

3. Shell Programming and Scripting

pls help! complex find and replace

help pls... i would like to change this CURVE2 565489 789458 1258649 random data here... CURVE2 565489 568795 6548921 random data here... CURVE2 565489 123598 6446259 random data here... CURVE2 565489 672956 2489657 into this CURVE2 565489 586423 1258649 random data here...... (2 Replies)
Discussion started by: lakanino
2 Replies

4. UNIX for Advanced & Expert Users

complex find command

Hi all, I am trying to execute the following command: find 'path' -ls -exec cksum {} \; As you can see this simply finds files from a given path and runs cksum on them. My problem is this, if i have a FIFO in a directory the find tries to execute cksum on it and gets stuck. From the man page i... (9 Replies)
Discussion started by: noam128
9 Replies

5. Shell Programming and Scripting

find command with complex logic

I'm looking to write a script that will do a find of directories and delete them if they are older than x days but keep the last x # of folders even if they are older than x days. The usage is for a deployment location, so we want to keep the location clean but retain maybe the last 2 builds that... (5 Replies)
Discussion started by: MaureenT
5 Replies

6. Shell Programming and Scripting

Complex Script

hey... i had a big problem with my professor i have 3 simple archives in.txt -> had all timestamps of users logon (100lines) ex. 111111 222222 333333 out.txt -> had all timestamps of users logof (100lines) ex. 111113 222225 333332 commands.txt... (9 Replies)
Discussion started by: beandj
9 Replies

7. UNIX for Advanced & Expert Users

Help with complex find syntax

I need to modify the find command below to exclude the output of the directory /usr/UDPM/PerfMgmt/shmlck find / \( -fstype ctfs -o -fstype mntfs -o -fstype objfs -o -fstype proc -o ! local \) -prune -o -type f -perm -0002 -print 2>/dev/null I have tried many iterations and placement of... (2 Replies)
Discussion started by: interesting?
2 Replies

8. Shell Programming and Scripting

Complex find and replace only 1st instance string with dynamic combination

test.txt is the dynamic file but some of combination are fix like below are the lines ;wonder_off = ;wonder_off = disabled wonder_off = wonder_off = disabled the test.txt can content them in any order #cat test.xt ;wonder_off = ;wonder_off = disabled wonder_off = wonder_off =... (5 Replies)
Discussion started by: SilvesterJ
5 Replies

9. Shell Programming and Scripting

awk script (complex)

picked this up from another thread. echo 1st_file.csv; nawk -F, 'NR==FNR{a++;next} a{b++} END{for(i in b){if(b-1&&a!=b){print i";\t\t"b}else{print "NEW:"i";\t\t"b} } }' OFS=, 1st_file.csv *.csv | sort -r i need to use the above but with a slight modification.. 1.compare against 3 month... (25 Replies)
Discussion started by: slashbash
25 Replies

10. Shell Programming and Scripting

Help with Complex Bash Script

I have an FTP server with thousands of Invoices. All Invoices are in a folder called /volume1/MBSInvoices/ Monthly invoices are added to that folder every month. Here is a sample filename of the Invoices: invoice_1_20170101_10010052_10020052_10030052_JOHNDOE.pdf the Account ID is the... (6 Replies)
Discussion started by: badr777
6 Replies
JAZIPCONFIG(8)						      System Manager's Manual						    JAZIPCONFIG(8)

NAME
jazipconfig - jazip(1) configuration tool. SYNOPSIS
jazipconfig [--non-interactive] DESCRIPTION
The jazipconfig script is a tool to easily build the /etc/jazip.conf file for the configuration of jazip(1) OPTIONS
The optional --non-interactive command line parameter instructs jazipconfig to do what it can to build a /etc/jazip.conf file without prompting the user. On Debian systems, the command is invoked this way by the jazip package post-installation script. In this non-interactive mode, the script looks through /proc/scsi/scsi for detected Zip or Jaz devices. If it find any, it looks up /etc/fstab to see if it can find already specified mount points for them. If (and only if) it finds mount points, it writes the device and mount point to /etc/jazip.conf INTERACTIVE USE
If no command line options are provided, jazipconfig runs interactively. In this case, it also looks through /proc/scsi/scsi for detected Zip or Jaz devices. If it find any, it looks up /etc/fstab to see if it can find already specified mount points for them. Then it creates a user menu which you can use to create the /etc/jazip.conf file. NOTES
The first entry listed in /etc/jazip.conf is the default device used when jazip is called without an argument. SEE ALSO
jazip(1), jazip.conf(5) AUTHOR
Copyright (c) 1999 Peter S Galbraith <psg@debian.org> This manual page by Peter S Galbraith <psg@debian.org> for the Debian GNU/Linux system (but may be used by others). JAZIPCONFIG(8)
All times are GMT -4. The time now is 05:06 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy