Find script with input pattern file

Howdy:
I have a file with 140+ file name patterns. Each prefix can have dozens of files with different extension names.
e.g.
1-S51
1113-G6V
1117-G6V
1119-G6V
1127-G6V
12XW-AF5W
14-UA8N

I need to search in 12 directories, (/data/lgc1/basin_mas to /data/lgc12/basin_mas) for all the files.
The output (e.g. 1-S51___oan160001.1c1_fkd) has to be directed to a file, that lists the creator and the directory it is residing in.

I tried to use find /data/lcg*/basin_mas -name "1-S51*" -exec ls -lart {} \; 2>/dev/null >1.x
in a script (140+ lines long) with plans to cat all the *.x files together.
The script would only find some of the files. Most of the *.x files had a size of zero.
Yet, all 140+ files have at least 1 file on the system.

Can anyone suggest improvements to the script?
Or a script that would read in the prefixes, create a command and output the info?

Thanks.

Post an example that while the find command did not work. Be sure to say which files it missed.

The code was run in the same bash windows, once as a file and 11 times as commands pasted from the script into the command line.

#!/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

output files
-rw-rw-r-- 1 oneale expl 0 Feb 6 13:12 2.x
-rw-rw-r-- 1 oneale expl 0 Feb 6 13:12 3.x
-rw-rw-r-- 1 oneale expl 0 Feb 6 13:12 4.x
-rw-rw-r-- 1 oneale expl 0 Feb 6 13:12 5.x
-rw-rw-r-- 1 oneale expl 0 Feb 6 13:12 7.x
-rw-rw-r-- 1 oneale expl 0 Feb 6 13:12 6.x
-rw-rw-r-- 1 oneale expl 0 Feb 6 13:12 9.x
-rw-rw-r-- 1 oneale expl 0 Feb 6 13:12 8.x
-rw-rw-r-- 1 oneale expl 0 Feb 6 13:12 10.x
-rw-rw-r-- 1 oneale expl 348 Feb 6 13:12 11.x

output of only non-zero file
-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

Now running the commands 1 at a time with ".z" as the extension.

output files
-rw-rw-r-- 1 oneale expl 146 Feb 6 13:08 2.z
-rw-rw-r-- 1 oneale expl 250 Feb 6 13:18 3.z
-rw-rw-r-- 1 oneale expl 250 Feb 6 13:18 4.z
-rw-rw-r-- 1 oneale expl 250 Feb 6 13:18 5.z
-rw-rw-r-- 1 oneale expl 424 Feb 6 13:18 6.z
-rw-rw-r-- 1 oneale expl 521 Feb 6 13:22 7.z
-rw-rw-r-- 1 oneale expl 1565 Feb 6 13:14 8.z
-rw-rw-r-- 1 oneale expl 250 Feb 6 13:20 9.z
-rw-rw-r-- 1 oneale expl 521 Feb 6 13:20 10.z
-rw-rw-r-- 1 oneale expl 2416 Feb 6 13:11 11.z

output of 11.z
-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

Suggestions welcome.

Notice the name of the directory: /data/lgc*/basin_mas/

It seems you have created a directory that quite literally contains an asterisk. That seems to be the only directory you are searching.

The asterik is not the problem.

The original script output only found one set of files. (11.x)
And it put lgc* as the directory (not very helpful)

Why does running the commands 1 at a time produce 11 files, with more data in 11.z than 11.x?
The same command one in batch, one typed in.

The asterisk is the problem. Putting lgc* as the directory is extremely helpful. Do you understand what "It seems you have created a directory that quite literally contains an asterisk. " means?

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

I'm not a bash expert, but looking up that -f on your script, I see: (From the bash man page): "-f Disable pathname expansion." Maybe your interactive shell is not also an instance of bash which has path name expansion disabled? But you really need a bash expert here...

YOU ARE!

I looked at the script 700 times and couldn't see the "-f".

I took it out, the script runs PERFECTLY!!!

Thanks for your time.