Unix Shell Programming: Add a blank line when printing

后端 未结 5 1438
盖世英雄少女心
盖世英雄少女心 2021-01-28 13:17

I am trying to list all the files in the directory but how would you separate each of the files by a blank line? basically each file displayed by separated by a blank line? I am

5条回答
  •  野趣味
    野趣味 (楼主)
    2021-01-28 14:14

    Your loops are close. However, using a traditional bash for loop with ls is dangerous - what happens if your filenames contain spaces? An easy solution with awk:

    ls | awk '{ print $0 "\n" }'
    

提交回复
热议问题