Find Command in Bash Script Resulting in "No Such File or Directory" Error Only for Directories

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



Leave a reply



Submit