Reputation: 229
I have a file like this below,
#!/bin/bash
i=1
export basename=z-4-1_
in file "1.bash" I would like to keep as is but in file "2.bash" I would like to change in to z-4-2_ and in file "3.bash" I would like to change in to z-4-3_, and on until I get to 15.
how would like tackle this problem? by using script to modify these numbers in different files.
Upvotes: 0
Views: 1838
Reputation: 17198
Somewhat shorter:
for i in {1..15}
do
echo -e "#!/bin/bash\ni=1\nexport basename=z-4-${i}_" > $i.bash
done
Upvotes: 0
Reputation: 1083
This script should do it for you:
#!/bin/bash
for i in {1..15}
do
touch file$i.bash
echo '#!/bin/bash' >> file$i.bash
echo 'i=1' >> file$i.bash
echo 'export basename=z-4-'$i'_' >> file$i.bash
done
Upvotes: 2