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.
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
Somewhat shorter:
for i in {1..15}
do
echo -e "#!/bin/bash\ni=1\nexport basename=z-4-${i}_" > $i.bash
done
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.