Using a count variable in a file name

前端 未结 2 1413
灰色年华
灰色年华 2021-01-17 14:54

I have a quick question. I just wanted to know if it was valid format (using bash shell scripting) to have a counter for a loop in a file name. I am thinking something along

2条回答
  •  清歌不尽
    2021-01-17 15:53

    If you only want to make a bunch of files and don't need the loop for anything else, you can skip the loop altogether:

    touch file{1..12}.txt
    

    will make them all in one command.

    If you have Bash 4, you can get leading zeros like this:

    touch file{01..12}.txt
    

提交回复
热议问题