0

论证示例:

../path/cse/lab3/remove

现在,它正在打印“lab3”中的所有目录和文件。我希望它打印出“删除”中的所有文件。我不知道该怎么做。我想使用 for 循环。

代码:

if test -d $1    #check if argument is a directory.
then

    for fileName in *
    do  
        echo "what is this::: $fileName"

    done

fi

另外,我如何将所有文件打印为字符串,如下所示:

remove/test.out
remove/test2.out
4

1 回答 1

2
for fileName in $1/*

……大概就是你的意思。

于 2012-11-26T02:54:31.360 回答