mirror of
https://github.com/0glabs/0g-storage-node.git
synced 2025-04-02 22:45:41 +00:00
Merge 80fd9e1a91
into 74074dfa2f
This commit is contained in:
commit
3e878c4348
@ -3,13 +3,19 @@
|
|||||||
directory="$1" # The directory to search in
|
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
|
# Ensure both arguments are provided
|
||||||
found_files=$(find "$directory" -type f -name "$filename")
|
if [ -z "$directory" ] || [ -z "$filename" ]; then
|
||||||
|
echo "Usage: $0 <directory> <filename>" >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Find the file and store results in an array
|
||||||
|
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
|
||||||
|
Loading…
Reference in New Issue
Block a user