Unix Shell Programming: Add a blank line when printing

后端 未结 5 1440
盖世英雄少女心
盖世英雄少女心 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

    Not sure how portable the options -d and -t are, but pr is ubiquitous:

    $ ls | pr -dt
    

    Note that any file names with an embedded carriage return will have an extra carriage return added in the output. (I believe that problem occurs with all of the solutions presented so far.)

提交回复
热议问题