-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
15c4167
commit a3f0c7f
Showing
2 changed files
with
23 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
#!/bin/bash | ||
|
||
# Check if a path is provided | ||
if [ -z "$1" ]; then | ||
echo "Usage: $0 <directory-path>" | ||
exit 1 | ||
fi | ||
|
||
# Assign the provided path to a variable | ||
DIR="$1" | ||
|
||
# Check if the provided path is a valid directory | ||
if [ ! -d "$DIR" ]; then | ||
echo "Error: $DIR is not a valid directory." | ||
exit 1 | ||
fi | ||
|
||
# Find files, check MIME type, and count text files | ||
total_text_files=$(find "$DIR" -type f -exec file --mime-type {} + | grep -c "text/") | ||
|
||
# Output the result | ||
echo "Total text files in '$DIR' and its subdirectories: $total_text_files" |