Define function in unix/linux command line (e.g. BASH)

后端 未结 5 1289
时光说笑
时光说笑 2021-01-04 00:21

Sometimes I have a one-liner that I am repeating many times for a particular task, but will likely never use again in the exact same form. It includes a file name that I am

5条回答
  •  一整个雨季
    2021-01-04 01:09

    Don't use ls | wc -l as it may give you wrong results if file names have newlines in it. You can use this function instead:

    numresults() { find "$1" -mindepth 1 -printf '.' | wc -c; }
    

提交回复
热议问题