Count files and directories using shell script

后端 未结 5 636
悲&欢浪女
悲&欢浪女 2021-01-01 18:49

I\'m learning bash scripting and have written a script to count the files and directories in the directory that is supplied as argument. I have it working one way which seem

5条回答
  •  轻奢々
    轻奢々 (楼主)
    2021-01-01 19:45

    ... am wondering if there is a simpler way of doing it.

    If you say so ;)

    Alternatively, reduce your script to

    find /path/to/directory | wc -l
    

    For current directory, do:

    find . | wc -l
    

提交回复
热议问题