Repeat 3000 times a sequence of characters âOW HW1 HW2â in a column
Clash Royale CLAN TAG#URR8PPP
up vote
1
down vote
favorite
I would like to have the following sequence:
OW
HW1
HW2
being repeated in an output file 3000 times such as:
OW
HW1
HW2
.
.
.
OW
HW1
HW2
I believe I can, by using bash, set the OW, HW1 and HW2 as independent variable and then make a do loop 3000 times and print the values in the output file.
bash
add a comment |Â
up vote
1
down vote
favorite
I would like to have the following sequence:
OW
HW1
HW2
being repeated in an output file 3000 times such as:
OW
HW1
HW2
.
.
.
OW
HW1
HW2
I believe I can, by using bash, set the OW, HW1 and HW2 as independent variable and then make a do loop 3000 times and print the values in the output file.
bash
add a comment |Â
up vote
1
down vote
favorite
up vote
1
down vote
favorite
I would like to have the following sequence:
OW
HW1
HW2
being repeated in an output file 3000 times such as:
OW
HW1
HW2
.
.
.
OW
HW1
HW2
I believe I can, by using bash, set the OW, HW1 and HW2 as independent variable and then make a do loop 3000 times and print the values in the output file.
bash
I would like to have the following sequence:
OW
HW1
HW2
being repeated in an output file 3000 times such as:
OW
HW1
HW2
.
.
.
OW
HW1
HW2
I believe I can, by using bash, set the OW, HW1 and HW2 as independent variable and then make a do loop 3000 times and print the values in the output file.
bash
bash
edited 36 mins ago
Rui F Ribeiro
37.1k1273118
37.1k1273118
asked 2 hours ago
Dimitris Mintis
161
161
add a comment |Â
add a comment |Â
5 Answers
5
active
oldest
votes
up vote
4
down vote
You can use this printf
trick with a zero-length string specifier %.0s
and brace expansion:
printf '%.0sOWnHW1nHW2n' 1..3000 > newfile
super this works just perfect!!!!
â Dimitris Mintis
1 hour ago
add a comment |Â
up vote
2
down vote
It can be easily done with Perl:
perl -e'print "OWnHW1nHW2n"x3000'
add a comment |Â
up vote
1
down vote
If use for
in
cycle:
for i in $(seq 1 3000) ; do echo -e "OWnHW1nHW2"; done
or use echo 3x
for i in $(seq 1 3000) ; do echo OW; echo HW1; echo HW2; done
This is great, but then how do I print this sequence 3000 times in the file?
â Dimitris Mintis
1 hour ago
Use redirection:for i in $(seq 1 3000) ; do echo -e "OWnHW1nHW2" >>file.txt ; done
â schweik
1 hour ago
add a comment |Â
up vote
0
down vote
you can use a while loop like here: http://www.tldp.org/LDP/Bash-Beginners-Guide/html/sect_09_02.html
An example:
COUNTER=0; while [ $COUNTER -lt 3 ]; do echo "$COUNTER" && COUNTER=$((COUNTER+1)); done
Don't forget to reset the COUNTER every time you want to run this.
New contributor
add a comment |Â
up vote
0
down vote
If your shell offers "brace expansion", try
echo $'nOHnHW1nHW2n'1..3000$'n' | grep -Ev "^( |[0-9])*$"
OH
HW1
HW2
OH
HW1
HW2
OH
HW1
HW2
.
.
.
and redirect to a file if happy with the result.
add a comment |Â
5 Answers
5
active
oldest
votes
5 Answers
5
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
4
down vote
You can use this printf
trick with a zero-length string specifier %.0s
and brace expansion:
printf '%.0sOWnHW1nHW2n' 1..3000 > newfile
super this works just perfect!!!!
â Dimitris Mintis
1 hour ago
add a comment |Â
up vote
4
down vote
You can use this printf
trick with a zero-length string specifier %.0s
and brace expansion:
printf '%.0sOWnHW1nHW2n' 1..3000 > newfile
super this works just perfect!!!!
â Dimitris Mintis
1 hour ago
add a comment |Â
up vote
4
down vote
up vote
4
down vote
You can use this printf
trick with a zero-length string specifier %.0s
and brace expansion:
printf '%.0sOWnHW1nHW2n' 1..3000 > newfile
You can use this printf
trick with a zero-length string specifier %.0s
and brace expansion:
printf '%.0sOWnHW1nHW2n' 1..3000 > newfile
answered 1 hour ago
steeldriver
32.9k34981
32.9k34981
super this works just perfect!!!!
â Dimitris Mintis
1 hour ago
add a comment |Â
super this works just perfect!!!!
â Dimitris Mintis
1 hour ago
super this works just perfect!!!!
â Dimitris Mintis
1 hour ago
super this works just perfect!!!!
â Dimitris Mintis
1 hour ago
add a comment |Â
up vote
2
down vote
It can be easily done with Perl:
perl -e'print "OWnHW1nHW2n"x3000'
add a comment |Â
up vote
2
down vote
It can be easily done with Perl:
perl -e'print "OWnHW1nHW2n"x3000'
add a comment |Â
up vote
2
down vote
up vote
2
down vote
It can be easily done with Perl:
perl -e'print "OWnHW1nHW2n"x3000'
It can be easily done with Perl:
perl -e'print "OWnHW1nHW2n"x3000'
answered 1 hour ago
Tomasz
8,50552760
8,50552760
add a comment |Â
add a comment |Â
up vote
1
down vote
If use for
in
cycle:
for i in $(seq 1 3000) ; do echo -e "OWnHW1nHW2"; done
or use echo 3x
for i in $(seq 1 3000) ; do echo OW; echo HW1; echo HW2; done
This is great, but then how do I print this sequence 3000 times in the file?
â Dimitris Mintis
1 hour ago
Use redirection:for i in $(seq 1 3000) ; do echo -e "OWnHW1nHW2" >>file.txt ; done
â schweik
1 hour ago
add a comment |Â
up vote
1
down vote
If use for
in
cycle:
for i in $(seq 1 3000) ; do echo -e "OWnHW1nHW2"; done
or use echo 3x
for i in $(seq 1 3000) ; do echo OW; echo HW1; echo HW2; done
This is great, but then how do I print this sequence 3000 times in the file?
â Dimitris Mintis
1 hour ago
Use redirection:for i in $(seq 1 3000) ; do echo -e "OWnHW1nHW2" >>file.txt ; done
â schweik
1 hour ago
add a comment |Â
up vote
1
down vote
up vote
1
down vote
If use for
in
cycle:
for i in $(seq 1 3000) ; do echo -e "OWnHW1nHW2"; done
or use echo 3x
for i in $(seq 1 3000) ; do echo OW; echo HW1; echo HW2; done
If use for
in
cycle:
for i in $(seq 1 3000) ; do echo -e "OWnHW1nHW2"; done
or use echo 3x
for i in $(seq 1 3000) ; do echo OW; echo HW1; echo HW2; done
answered 1 hour ago
schweik
3004
3004
This is great, but then how do I print this sequence 3000 times in the file?
â Dimitris Mintis
1 hour ago
Use redirection:for i in $(seq 1 3000) ; do echo -e "OWnHW1nHW2" >>file.txt ; done
â schweik
1 hour ago
add a comment |Â
This is great, but then how do I print this sequence 3000 times in the file?
â Dimitris Mintis
1 hour ago
Use redirection:for i in $(seq 1 3000) ; do echo -e "OWnHW1nHW2" >>file.txt ; done
â schweik
1 hour ago
This is great, but then how do I print this sequence 3000 times in the file?
â Dimitris Mintis
1 hour ago
This is great, but then how do I print this sequence 3000 times in the file?
â Dimitris Mintis
1 hour ago
Use redirection:
for i in $(seq 1 3000) ; do echo -e "OWnHW1nHW2" >>file.txt ; done
â schweik
1 hour ago
Use redirection:
for i in $(seq 1 3000) ; do echo -e "OWnHW1nHW2" >>file.txt ; done
â schweik
1 hour ago
add a comment |Â
up vote
0
down vote
you can use a while loop like here: http://www.tldp.org/LDP/Bash-Beginners-Guide/html/sect_09_02.html
An example:
COUNTER=0; while [ $COUNTER -lt 3 ]; do echo "$COUNTER" && COUNTER=$((COUNTER+1)); done
Don't forget to reset the COUNTER every time you want to run this.
New contributor
add a comment |Â
up vote
0
down vote
you can use a while loop like here: http://www.tldp.org/LDP/Bash-Beginners-Guide/html/sect_09_02.html
An example:
COUNTER=0; while [ $COUNTER -lt 3 ]; do echo "$COUNTER" && COUNTER=$((COUNTER+1)); done
Don't forget to reset the COUNTER every time you want to run this.
New contributor
add a comment |Â
up vote
0
down vote
up vote
0
down vote
you can use a while loop like here: http://www.tldp.org/LDP/Bash-Beginners-Guide/html/sect_09_02.html
An example:
COUNTER=0; while [ $COUNTER -lt 3 ]; do echo "$COUNTER" && COUNTER=$((COUNTER+1)); done
Don't forget to reset the COUNTER every time you want to run this.
New contributor
you can use a while loop like here: http://www.tldp.org/LDP/Bash-Beginners-Guide/html/sect_09_02.html
An example:
COUNTER=0; while [ $COUNTER -lt 3 ]; do echo "$COUNTER" && COUNTER=$((COUNTER+1)); done
Don't forget to reset the COUNTER every time you want to run this.
New contributor
New contributor
answered 1 hour ago
Timo
11
11
New contributor
New contributor
add a comment |Â
add a comment |Â
up vote
0
down vote
If your shell offers "brace expansion", try
echo $'nOHnHW1nHW2n'1..3000$'n' | grep -Ev "^( |[0-9])*$"
OH
HW1
HW2
OH
HW1
HW2
OH
HW1
HW2
.
.
.
and redirect to a file if happy with the result.
add a comment |Â
up vote
0
down vote
If your shell offers "brace expansion", try
echo $'nOHnHW1nHW2n'1..3000$'n' | grep -Ev "^( |[0-9])*$"
OH
HW1
HW2
OH
HW1
HW2
OH
HW1
HW2
.
.
.
and redirect to a file if happy with the result.
add a comment |Â
up vote
0
down vote
up vote
0
down vote
If your shell offers "brace expansion", try
echo $'nOHnHW1nHW2n'1..3000$'n' | grep -Ev "^( |[0-9])*$"
OH
HW1
HW2
OH
HW1
HW2
OH
HW1
HW2
.
.
.
and redirect to a file if happy with the result.
If your shell offers "brace expansion", try
echo $'nOHnHW1nHW2n'1..3000$'n' | grep -Ev "^( |[0-9])*$"
OH
HW1
HW2
OH
HW1
HW2
OH
HW1
HW2
.
.
.
and redirect to a file if happy with the result.
answered 1 hour ago
RudiC
1,90219
1,90219
add a comment |Â
add a comment |Â
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f475040%2frepeat-3000-times-a-sequence-of-characters-ow-hw1-hw2-in-a-column%23new-answer', 'question_page');
);
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password