|
|
Question : Copy and paste lines in a file, bash scripting
|
|
I've searched the web on basic bash, sed and awk scripting and can find nothing simple enough to answer this question: how do I copy and paste lines in a file? I have a file containing the line in the script below, but don't know how to paste it 50 times with vi, so I thought I'd run a script to do that. I copy my latest attempt below, which would print the lines to stdout, but if I run it as copy.sh > test.dat, it should copy them to a file. TIA
Code Snippet:
1:
2:
3:
4:
5:
6:
7:
8:
|
#!/bin/bash
LINE='03/14/08 01:00 PM,13,21,-8.32,-8.28,-8.27,-7.33,-7.31,-7.31,-7.23,-7.23,-7.24,-2.62,-2.64,-2.74,5.07,5.07,4.98,12.86,12.78,12.72,20,19.97,19.99,-7.23,-7.26,-7.23,-2.8,-2.47,-2.38,3.59,3.68,3.79,409.2,409.2,7.96,12.78,12.76,12.78,16.61,16.61,16.55,19.55,19.32,19.16,21.31,21.29,21.3,21.46,21.48,21.45,3.35,28.22,6.83,0.81'
i=1;
while i<50; do
echo $LINE
done
|
Open in New Window
Select All
|
Answer : Copy and paste lines in a file, bash scripting
|
|
what is missing in your script is redirecting output to a file and incrementing i
LINE='03/14/08 01:00 PM,13,21,-8.32,-8.28,-8.27,-7.33,-7.31,-7.31,-7.23,-7.23,-7.24,-2.62,-2.64,-2.74,5.07,5.07,4.98,12.86,12.78,12.72,20,19.97,19.99,-7.23,-7.26,-7.23,-2.8,-2.47,-2.38,3.59,3.68,3.79,409.2,409.2,7.96,12.78,12.76,12.78,16.61,16.61,16.55,19.55,19.32,19.16,21.31,21.29,21.3,21.46,21.48,21.45,3.35,28.22,6.83,0.81' i=1; while test $i -le 50 do echo $LINE >> file i=`expr $i + 1` done
|
|
|
|
|