find command in bash script resulting in No such file or directory error only for directories?
You don't need to escape DOT in shell glob as this is not regex. So use .AppleDouble
instead of \.AppleDouble
:
find $DIRTY_DIR -name .AppleDouble -exec rm -rf '{}' \;
PS: I don't see anywhere $COUNTER
being incremented in your script.
find command in bash script resulting in No such file or directory error only for directories?
You don't need to escape DOT in shell glob as this is not regex. So use .AppleDouble
instead of \.AppleDouble
:
find $DIRTY_DIR -name .AppleDouble -exec rm -rf '{}' \;
PS: I don't see anywhere $COUNTER
being incremented in your script.
find - suppress No such file or directory errors
You can redirect stderr
with 2>/dev/null
, for example:
find /mnt/16_c/$dir/data/ -mtime +180 -type f -exec echo {} \; 2>/dev/null
Btw, the code in your question can be replaced with:
find /mnt/16_c/*/data/ -mtime +180 -type f 2>/dev/null
And if there is at least one matching directory,
then you don't even need to suppress stderr
,
because find
will only search in directories that match this pattern.
No such file or directory but it exists
This error can mean that ./arm-mingw32ce-g++
doesn't exist (but it does), or that it exists and is a dynamically linked executable recognized by the kernel but whose dynamic loader is not available. You can see what dynamic loader is required by running ldd /arm-mingw32ce-g++
; anything marked not found
is the dynamic loader or a library that you need to install.
If you're trying to run a 32-bit binary on an amd64 installation:
- Up to Ubuntu 11.04, install the package
ia32-libs
. - On Ubuntu 11.10, install
ia32-libs-multiarch
. - Starting with 12.04, install
ia32-libs-multiarch
, or select a reasonable set of:i386
packages in addition to the:amd64
packages.
shell script: bad interpreter: No such file or directory when using pwd
Better do :
#!/bin/bash
count=0
dir="$PWD"
echo "$dir"
for file in "$dir"/*
do
if [[ -f $file ]]
then
((count++))
fi
done
echo $count
or a simplest/shortest solution :
#!/bin/bash
echo "$PWD"
for file; do
[[ -f $file ]] && ((count++))
done
echo $count
Related Topics
Prepend Data from One File to Another
What Does This Command Do? "Exec Bash -L"
Converting HTML to Odt, Doc, Docx
I Want to Use "Awk" or Sed to Print All the Lines That Start with "Comm=" in a File
X86_64 Linux Syscall Arguments
Why Doesn't This Call to 'Poll' Block Correctly on a Sysfs Device Attribute File
How to "Interconnect" Two Sockets in Linux
How to Set a Ulimit from Inside a Perl Script That Applies to Its Children
Run Command in Golang and Detach It from Process
Linux Command to Replace String in Large File with Another String
Poll(2) Doesn't Empty the Event Queue
How to Connect to Jenkins Server (Amazon Linux Ami)
Bash Printf %Q Invalid Directive
Apache Pig: Load a File That Shows Fine Using Hadoop Fs -Text
How to Disassemble Raw Mips Code
Why Gcc 4.X Default Reserve 8 Bytes for Stack on Linux When Calling a Method