How do I use awk to repeat a block of text 100 times?ie string1string2string3Would become:string1string2string3string1string2string3string1string2string3...
How to repeat a block of text?
text processing;awk
(where input is a file containing the text to repeat)With GNU awk (and assuming the input doesn't contain NUL bytes):awk -v n=100 -v RS='\0' -v ORS= '{while (n--) print}' < inputPortably:awk -v n=100 -v ORS= '  {all = all $0 RS}  END {while (n--) print all}' < input(note that if the input didn't end with a newline character, one will be added).You can also do things like:set --n=100; while [ $n -gt 0 ]; do  set -- $@ input  n=$((n - 1))donecat $@That one will work regardless of what byte input contains. Note however, that for larger values of n, and if your shell doesn't have cat builtin you may reach the system limit on the size of the arguments to a command (here cat).With zsh or recent versions of bash or ksh93 or yash -o braceexpand, for a fixed text you can do things like:printf '%.0sstring1\nstring2\nstring3\n' {1..100}With zsh:repeat 100 print -l string{1..3}If we're being cheeky, on systems with GNU seq installed, we can also do:seq -f 'string1string2string%.0g' 3.0001 0.0001 3.0100