Which means "$ 1 / *" in "for a file in $ 1 / *",

A short bash script below lists all the files and directories in this directory and its sub. What does $1/*the script mean ? Please give me some recommendations on this. Thanks

#!/bin/sh

list_alldir(){
    for file in $1/*
    do
        if [ -d $file ]; then
            echo $file
            list_alldir $file
        else
            echo $file
        fi
    done
}   

if [ $# -gt 0 ]; then 
    list_alldir "$1"
else
    list_alldir "."
fi
+5
source share
3 answers

This is the glob of the first argument, considered as a directory

bash script $0 ( script), $1, $2, $3... To , , . $* $@. ($* , $@ , $IFS)

+18

$1 .
for file in $1/* loop file, , .

+5

$1 - . . /asdf.sh a b c d e, $1 , $2 b .. $1 ..

+2

All Articles