In Linux if you type cat *, you will get something like this:
line1 from file1
line2 from file1
line1 from file2
line1 from file3
line2 from file3
line3 from file3
What I would like is to display a separator among files. Something like this:
line1 from file1
line2 from file1
XXXXXXXXXXXX
line1 from file2
XXXXXXXXXXXX
line1 from file3
line2 from file3
line3 from file3
Is that easily possible with a one-liner easy to type by heart?
If you're not too fussy about the appearance of the separator:
cd /to/your/directory; for each in *; do cat $each; echo "XXXXXXXXXXX"; done
Or
Or
Using only Bash (no
cat
):Edit:
In AWK 4:
You can use any separator such as the ones in the other examples in this answer. If you want the separator at the end of each file, change
BEGINFILE
toENDFILE
. It can still appear at the beginning of the script since it's a conditional (rather than implying execution order)..