I need to duplicate rows in text file with a specific number of times. For example my data file is:
jplg3350.18i
jplg3360.18i
jplg3370.18i
I need to duplicate the lines three times as follows;
jplg3350.18i
jplg3360.18i
jplg3370.18i
jplg3350.18i
jplg3360.18i
jplg3370.18i
jplg3350.18i
jplg3360.18i
jplg3370.18i
For 3 times you can just run:
And here is a trick if you're lazy like me and you don't want to re-type the file name N times. Type
cat
then the filename, Press Ctrl+W, then Ctrl+YSpaceN
times, finally type> new_file
.However it's a better idea to use a simple "loop" in combination with
cat
command.3 times example:
Or as you asked in comments:
Change '3' to any number you want.
Result: