Upload files to "OS/bash/Week4"

Signed-off-by: Aadit Agrawal <tech@aaditagrawal.com>
This commit is contained in:
Aadit Agrawal 2025-01-24 10:06:30 +05:30
parent 3d5dfd6481
commit 5b0eda8b4e
5 changed files with 108 additions and 0 deletions

24
OS/bash/Week4/q4.sh Normal file
View file

@ -0,0 +1,24 @@
#!/bin/bash
opt="$1"
file="$2"
case "$opt" in
-linecount)
result=$(wc -l < "$file")
echo "Line count in $file: $result"
;;
-wordcount)
result=$(wc -w < "$file")
echo "Word count in $file: $result"
;;
-charcount)
result=$(wc -c < "$file")
echo "Character count in $file: $result"
;;
*)
echo "Invalid option. Please use -linecount, -wordcount, or -charcount."
exit 1
;;
esac