Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Linux Find Command

What am I doing wrong with the FIND command? I can't figure out why this works:

find /home/michael/foxpro/mount/A1/[12][0-9][0-9][0-9] "*.dbf" -type f -exec ln -s {} \;
find /home/michael/foxpro/mount/AF/[12][0-9][0-9][0-9] "*.dbf" -type f -exec ln -s {} \;
find /home/michael/foxpro/mount/AV/[12][0-9][0-9][0-9] "*.dbf" -type f -exec ln -s {} \;

but this doesn't:

find /home/michael/foxpro/mount/[A1][AF][AV]/[12][0-9][0-9][0-9] "*.dbf" -type f -exec ln -s {} \;

My folder structure looks like this:

...../mount/A1/2012/file1.dbf
...../mount/A1/2011/file2.dbf
...../mount/A1/2010/file3.dbf
...../mount/AF/2012/file4.dbf
...../mount/AF/2011/file5.dbf
...../mount/AF/2010/file6.dbf
...

The first script when I hard code the second to last directory the find scan through all my year directories but in my second script it just gives me a "No such file or directory" error.

like image 251
Michael Black Avatar asked Apr 01 '26 14:04

Michael Black


1 Answers

The pattern [A1][AF][AV] matches the following files/directories: AAA, AAV, AFA, AFV, 1AA, 1AV, …

To match the directories A1, AF, AV, use the pattern A[1FV] or {A1,AF,AV}.

like image 122
knittl Avatar answered Apr 03 '26 04:04

knittl



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!