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

4 Answers4

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}'
jesse_b
  • 37,005
4
NAME
       pr - convert text files for printing

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

… | pr -dt

poige
  • 6,231
2

One more:

ls (options) | while read LINE; do
  echo "$LINE
"
done
WGroleau
  • 205