The input file contains below lines:
a
b
c
I want the output as(n times):
a
b
c
a
b
c
I've tried below command but it doesn't maintain the order
while read line; do for i in {1..4}; do echo "$line"; done; done < file
but the output is
a
a
b
b
c
c
printf
andbrace expansion
can be used to repeat a string N times, which can then be passed as input tocat
which does its job of concatenateWith
perl
, if file is small enough for memory requirements to be slurped wholeUsing
seq
withxargs
:A small solution for printing
file
3 times:The command substitution
$()
expands tocat file file file
. This works only for filenames without whitespace. SetIFS=$'\n'
if your file name contains spaces or tabulators.Another solution could be