I need to search all files whose name contain string 'bind' through a mounted usb key (the search should exclude a directory called 'prog/'
Here is the mounted volume:
lsblk /dev/sda
sda 8:0 1 58.6G 0 disk
└─sda1 8:1 1 58.6G 0 part /run/media/achille/1af1ba16-5f9a-44af-a481-9e8c63d278e1
Here is the search root directory in the usb key:
ls /run/media/achille/1af1ba16-5f9a-44af-a481-9e8c63d278e1/it0/
linux/
new_order/
prog/
it looks like the find command does not work the same way depending on where you are in the path:
pwd
/run/media
find ./achille/1af1ba16-5f9a-44af-a481-9e8c63d278e1/it0/ \
-path ./achille/1af1ba16-5f9a-44af-a481-9e8c63d278e1/it0/prog -prune \
-o -type f -iname *bind* -print 2>/dev/null
./achille/1af1ba16-5f9a-44af-a481-9e8c63d278e1/it0/new_order/bash/scripts/kubernetes-vagrant-centos-cluster-master/addon/rook/rook-agent-clusterrolebinding.yaml
-> it works but,
cd ..;pwd
/run
I recall the same working command (see above), and add 'media' between './' and 'achille':
find ./media/achille/1af1ba16-5f9a-44af-a481-9e8c63d278e1/it0/ \
-path ./media/achille/1af1ba16-5f9a-44af-a481-9e8c63d278e1/it0/prog -prune \
-o -type f -iname *bind* -print 2>/dev/null
-> it outputs nothing !! why?? I just recall the same command one directory further.If I specify the full path it outputs nothing either.
many thanx folks!
-Lto follow symbolic links.find $folder -type f -not -ipath '*/prog/*' -iname '*bind*'