Sponsored Content
Top Forums Shell Programming and Scripting Find script with input pattern file Post 98170 by iguanathompson on Monday 6th of February 2006 04:51:24 PM
Old 02-06-2006
Why two different answers, then.

Okay, I've must have an lgc* directory somewhere.
I can't see it.

The question then is why does the script not return the same results as the single line commands?

#!/bin/bash -f
find /data/lgc*/basin_mas -name "1-S51*" -exec ls -lart {} \; 2>/dev/null >2.x
find /data/lgc*/basin_mas -name "1113-G6V*" -exec ls -lart {} \; 2>/dev/null >3.x
find /data/lgc*/basin_mas -name "1117-G6V*" -exec ls -lart {} \; 2>/dev/null >4.x
find /data/lgc*/basin_mas -name "1119-G6V*" -exec ls -lart {} \; 2>/dev/null >5.x
find /data/lgc*/basin_mas -name "1127-G6V*" -exec ls -lart {} \; 2>/dev/null >6.x
find /data/lgc*/basin_mas -name "12XW-AF5W*" -exec ls -lart {} \; 2>/dev/null >7.x
find /data/lgc*/basin_mas -name "14-UA8N*" -exec ls -lart {} \; 2>/dev/null >8.x
find /data/lgc*/basin_mas -name "150-F7U*" -exec ls -lart {} \; 2>/dev/null >9.x
find /data/lgc*/basin_mas -name "16X-AF5W*" -exec ls -lart {} \; 2>/dev/null >10.x
find /data/lgc*/basin_mas -name "2-V5*" -exec ls -lart {} \; 2>/dev/null >11.x

return this
-rw-rw-r-- 1 oneale expl 0 Feb 6 14:43 2.x
-rw-rw-r-- 1 oneale expl 0 Feb 6 14:43 3.x
-rw-rw-r-- 1 oneale expl 0 Feb 6 14:43 4.x
-rw-rw-r-- 1 oneale expl 0 Feb 6 14:44 5.x
-rw-rw-r-- 1 oneale expl 0 Feb 6 14:44 7.x
-rw-rw-r-- 1 oneale expl 0 Feb 6 14:44 6.x
-rw-rw-r-- 1 oneale expl 0 Feb 6 14:44 9.x
-rw-rw-r-- 1 oneale expl 0 Feb 6 14:44 8.x
-rw-rw-r-- 1 oneale expl 0 Feb 6 14:44 10.x
-rw-rw-r-- 1 oneale expl 348 Feb 6 14:44 11.x

with 11.x containing
-rw-rw-r-- 1 33682 expl 1296 Feb 19 2004 /data/lgc*/basin_mas/2-V5__________________________LEDUC_WABAMUN_iso______________________
_____________________.hzd_glb
-rw-rw-r-- 1 34124 expl 1296 Jan 15 2004 /data/lgc*/basin_mas/2-V5__________________________REG_WABAMUN_merge______________________
_____________________.hzd_glb

But when you run the command separately
find /data/lgc*/basin_mas -name "2-V5*" -exec ls -lart {} \; 2>/dev/null >11.z
you get
-rw-rw-r-- 1 oneale expl 2764 Feb 6 14:45 11.z
with 11.z containing.
-rw-rw-r-- 1 33682 expl 1296 Feb 19 2004 /data/lgc*/basin_mas/2-V5__________________________LEDUC_WABAMUN_iso______________________
_____________________.hzd_glb
-rw-rw-r-- 1 34124 expl 1296 Jan 15 2004 /data/lgc*/basin_mas/2-V5__________________________REG_WABAMUN_merge______________________
_____________________.hzd_glb
-rw-rw-r-- 1 33682 expl 1296 Feb 19 2004 /data/lgc10/basin_mas/2-V5__________________________LEDUC_WABAMUN_iso_____________________
______________________.hzd_glb
-rw-rw-r-- 1 34124 expl 1296 Jan 15 2004 /data/lgc10/basin_mas/2-V5__________________________REG_WABAMUN_merge_____________________
______________________.hzd_glb
-rw-rw-r-- 1 33682 expl 1296 Oct 20 2003 /data/lgc2/basin_mas/2-V5__________________________NISKU__________________________________
_____________________.hzd_glb
-rw-rw-r-- 1 33682 expl 1296 Oct 21 2003 /data/lgc2/basin_mas/2-V5__________________________NISKU_WABAMUN_isochron_________________
_____________________.hzd_glb
-rw-rw-r-- 1 jbutlin expl 924876 May 8 2002 /data/lgc3/basin_mas/2-V5__________________________cnc16000102.2v2_glb
-rw-rw-r-- 1 jbutlin expl 8044 Sep 30 2003 /data/lgc3/basin_mas/2-V5__________________________cnc16000101.2v2_glb
-rw-rw-r-- 1 33682 expl 1296 Oct 7 2003 /data/lgc8/basin_mas/2-V5__________________________WABAMUN_new____________________________
_____________________.hzd_glb
-rw-rw-r-- 1 33682 expl 1296 Oct 14 2003 /data/lgc8/basin_mas/2-V5__________________________LEDUC__________________________________
_____________________.hzd_glb
-rw-rw-r-- 1 33682 expl 1296 Oct 14 2003 /data/lgc8/basin_mas/2-V5__________________________WABAMUN_reg____________________________
_____________________.hzd_glb
-rw-rw-r-- 1 33682 expl 8044 Aug 25 2004 /data/lgc8/basin_mas/2-V5__________________________reg16tied01.2v2_glb
-rw-rw-r-- 1 33682 expl 924876 Oct 14 2003 /data/lgc8/basin_mas/2-V5__________________________reg16tied02.2v2_glb
-rw-rw-r-- 1 34124 expl 1296 May 4 2004 /data/lgc8/basin_mas/2-V5__________________________MH_Nordegg_____________________________
_____________________.hzd_glb
-rw-rw-r-- 1 34124 expl 1296 Jul 14 2003 /data/lgc8/basin_mas/2-V5__________________________MH_Wabamun_____________________________
_____________________.hzd_glb
-rw-rw-r-- 1 34124 expl 1296 Aug 28 2003 /data/lgc8/basin_mas/2-V5__________________________REG_WABAMUN____________________________
_____________________.hzd_glb
-rw-rw-r-- 1 33682 expl 1296 Oct 9 2003 /data/lgc9/basin_mas/2-V5__________________________WABAMUN________________________________
_____________________.hzd_glb
 

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Script to find file name for non matching pattern

Hi, I want to list only the file names which do not contain a specific keyword or search string. OS: Solaris Also is there any way ; through the same script I can save the output of search to a CSV (comma seperated) so that the file can be used for inventory purpose. Any assistance will... (5 Replies)
Discussion started by: sujoy101
5 Replies

2. Shell Programming and Scripting

Need script to take input from file, match on it in file 2 and input data

All, I am trying to figure out a script to run in windows that will allow me to match on First column in file1 to 8th Column in File2 then Insert file1 column2 to file2 column4 then create a new file. File1: 12345 Sam 12346 Bob 12347 Bill File2:... (1 Reply)
Discussion started by: darkoth
1 Replies

3. UNIX for Dummies Questions & Answers

How i input a pattern into a file where it does not exist

I have a strange problem and i am wondering the best way to tackel it. i have hundres of files. in each of these files i would like to see a representative of each of my animals at the start of each line, in this case mouse, cat, dog, pig, rabbit, in this exact order. However not all of my... (2 Replies)
Discussion started by: cavanac2
2 Replies

4. Shell Programming and Scripting

Script to delete files with an input for directories and an input for path/file

Hello, I'm trying to figure out how best to approach this script, and I have very little experience, so I could use all the help I can get. :wall: I regularly need to delete files from many directories. A file with the same name may exist any number of times in different subdirectories.... (3 Replies)
Discussion started by: *ShadowCat*
3 Replies

5. Shell Programming and Scripting

Script to find duplicate pattern in a file irrespective of case

We have a configuration file in Unix. In that we have entries like below. if it ends with ":", then it is the end of record. We need to find our if there is any duplicate entries like ABCD irrespective of the case. ABCD:\ :conn.retry.stwait=00.00.30:\ :sess.pnode.max=255:\ ... (9 Replies)
Discussion started by: johnjs
9 Replies

6. Shell Programming and Scripting

How to find a file with a specific pattern for current sysdate & upon find email the details?

I need assistance with following requirement, I am new to Unix. I want to do the following task but stuck with file creation date(sysdate) Following is the requirement I need to create a script that will read the abc/xyz/klm folder and look for *.err files for that day’s date and then send an... (4 Replies)
Discussion started by: PreetArul
4 Replies

7. Shell Programming and Scripting

Search pattern in a file taking input from another file

Hi, Below is my requirement File1: svasjsdhvassdvasdhhgvasddhvasdhasdjhvasdjsahvasdjvdasjdvvsadjhv vdjvsdjasvdasdjbasdjbasdjhasbdasjhdbjheasbdasjdsajhbjasbjasbhddjb svfsdhgvfdshgvfsdhfvsdadhfvsajhvasjdhvsajhdvsadjvhasjhdvjhsadjahs File2: sdh hgv I need a command such that... (8 Replies)
Discussion started by: imrandec85
8 Replies

8. UNIX for Beginners Questions & Answers

Reducing input file size after pattern search

I have a very large file with millions of entries identified by @M. I am using the following script to "extract" entries based on specific strings/patterns: #!/bin/bash if ] then file=$1 else echo "Input_file passed as an argument $1 is NOT found." exit; fi MID=(NULL "string-1"... (10 Replies)
Discussion started by: Xterra
10 Replies

9. Shell Programming and Scripting

Copy data to new file based on input pattern

Hi All, I want to create a new file based on certain conditions and copy only those conditioned data to new file. Input Data is as it looks below. ORDER|Header|Add|32|32|1616 ORDER|Details1......... ORDER|Details2......... ORDER|Details3......... ORDER|Details4............ (10 Replies)
Discussion started by: grvk101
10 Replies
All times are GMT -4. The time now is 05:15 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy