diff --git a/bash/bash2.sh b/bash/bash2.sh index 2f8a1f9..ecb54e7 100644 --- a/bash/bash2.sh +++ b/bash/bash2.sh @@ -1,2 +1,12 @@ -function countfiles() { -} +function countfiles(){ +if [ $# == 0 ] +then + echo "No arguments given. Usage: countfiles dir1 dir2 ..." +else + for i in $@ + do + echo $i has $(ls -1a $i | wc -l) files. + done +fi + } + diff --git a/bash2.sh b/bash2.sh new file mode 100644 index 0000000..2bbf19f --- /dev/null +++ b/bash2.sh @@ -0,0 +1,12 @@ +function countfiles(){ +if [ $# == 0 ] +then + echo "No arguments given. Usage: countfiles dir1 dir2 ..." +else + for i in $@ + do + echo $i has $(ls -1a $i | wc -l) files + done +fi + } +