I would like to know if a particular folder is present or not. I used the following command
find /mnt/md0/ -maxdepth 1 -name 'dcn'||'DCN'
I want to know if folder name is DCN or dcn .
How would I do this ?
You're looking for the option
-iname, which stands for "ignore case" on
GNU find along with the option
-type d for selecting only directories.
find /mnt/md0/ -type d -maxdepth 1 -iname dcn
As state in comment by Olivier Dulac to use with non GNU find or old find version you could use :
find /mnt/md0 -type d -maxdepth 1 -print | grep -i '/dcn$'
see this answer to have a real compatibility with non GNU and old find version
You can use this:
find /mnt/md0/ -type d -maxdepth 1 \( -name 'dcn' -o -name 'DCN' \)
find /mnt/md0/. ! -name . -prune -type d \( -name dcn -o -name DCN \)
Or for case insensitive match:
find /mnt/md0/. ! -name . -prune -type d -name '[dD][cC][nN]'
You don't necessarily need
printf '%s\n' /mnt/md0/[dD][cC][nN]/