Hello I want my script to output the following:
string1 string2
string1 string2 string2
string1 string2 string2 string2
string1 string2 string2 string2 string2
Etc. for about 20 times or so.
I've tried the following:
#! /bin/bash
string1=hello
string2=world
#for {i=1;i=<10;i=i+1};
#echo $string1 + $string2
#!/bin/bash
for ((number=1;number < 10;number++))
do
echo $string1 $string3
string2 *10
done;
exit 0
Now I can't find anything on the web about just looping and adding strings.. Thanks for any help! Greets
Your bash syntax is not correct.
#!/bin/bash
string1=hello
string2=world
output=$string1" "$string2
for i in {1..10} ; do
echo $output
output=$output" "$string2
done
Edit: or, taking into account the comments below for the sake of beauty of code:
#!/bin/bash
string1="hello"
string2="world"
output="$string1 $string2"
for ((i = 1; i <= 10; i++)) ; do
echo "$output"
output+=" $string2"
done
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With