This commit is contained in:
Bryer 2025-03-30 13:41:16 +03:00 committed by GitHub
commit 71331e352d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -4,12 +4,12 @@ directory="$1" # The directory to search in
filename="$2" # The filename to search for filename="$2" # The filename to search for
# Find the file in the directory # Find the file in the directory
found_files=$(find "$directory" -type f -name "$filename") mapfile -t found_files < <(find "$directory" -type f -name "$filename")
# Check if any files were found # Check if any files were found
if [ -z "$found_files" ]; then if [ ${#found_files[@]} -eq 0 ]; then
echo "Error: No files named '$filename' found in directory '$directory'." >&2 echo "Error: No files named '$filename' found in directory '$directory'." >&2
exit 1 exit 1
else else
echo "$found_files" printf "%s\n" "${found_files[@]}"
fi fi