15

This is standard ls -l output.

user@linux:~$ ls -l
total 0
-rw-rw-r-- 1 user user 0 Nov   1 00:00 file01
-rw-rw-r-- 1 user user 0 Nov   1 00:00 file02
-rw-rw-r-- 1 user user 0 Nov   1 00:00 file03
user@linux:~$ 

Would it be possible to add new line like this?

-rw-rw-r-- 1 user user 0 Nov   1 00:00 file01

-rw-rw-r-- 1 user user 0 Nov   1 00:00 file02

-rw-rw-r-- 1 user user 0 Nov   1 00:00 file03
2
  • 11
    But why? If it is to make it more readable, then consider changing to a different font, and different line spacing. Commented Nov 30, 2019 at 19:12
  • 1
    I agree with the above question. Please provide some rationale for your issue. Thank you. Commented Dec 1, 2019 at 7:25

4 Answers 4

21
ls -l | sed G

(that one is a common idiom and on the sed FAQ).

Or (likely faster, probably doesn't matter for the (likely short) output of ls -l):

ls -l | paste -d '\n' - /dev/null

Those insert a blank line after each line of the output of ls -l.

Now, if you want an empty line after each file described by ls -l, which would be different if there are files whose name contains newline characters, you would have to do something like:

for f in *; do ls -ld -- "$f" && echo; done

(which would also skip the total line).

Or you could use ls -ql which would make sure you get one line per file (the newline characters, like all control characters would be rendered as ? (at least in the POSIX locale)).

6

Using awk:

ls -l | awk '{printf "%s\n\n", $0}'
2
  • 2
    ... or perhaps more idiomatically, ls -l | awk 1 ORS='\n\n' Commented Nov 30, 2019 at 17:27
  • 1
    Or ls -l | awk '{print $0 "\n"}'
    – U. Windl
    Commented Dec 1, 2019 at 0:40
4
NAME
       pr - convert text files for printing

Interleaving with single empty line, w/o adding header:

… | pr -dt

1
  • 2
    Note that pr also treats formfeed characters specially in its input (with the behaviour varying between implementations) Commented Dec 1, 2019 at 7:57
2

One more:

ls (options) | while read LINE; do
  echo "$LINE
"
done
6

You must log in to answer this question.