Argument in bash script duplicates output
i wrote a Bash shell script which prints out information about file or directory, provided in argument,
but something went wrong, and if i put dir in argument, it does not show me the list of files

#!/bin/bash
for path in $1*
do
if [ -d $1 ]
then
echo "File: '$1'"
echo "Type: `stat -c%F $1`"
echo "Permissions: (`stat -c%a/%A $1`)"
echo "-----------"
elif [ -f $1 ]
then
echo "File: '$1'"
echo "Type: `stat -c%F $1`"
echo "Permissions: (`stat -c%a/%A $1`)"
echo "-----------"
fi
done
Ответы (1 шт):
Автор решения: user3851609
→ Ссылка
Correct Answer
#!/bin/bash
for path in $1*
do
if [ -d $path ]
then
echo "File: '$path'"
echo "Type: `stat -c%F $path`"
echo "Permissions: (`stat -c%a/%A $path`)"
echo "-----------"
elif [ -f $path ]
then
echo "File: '$path'"
echo "Type: `stat -c%F $path`"
echo "Permissions: (`stat -c%a/%A $path`)"
echo "-----------"
fi
done