How to write a ShellScript Bash for statement

Purpose

--Summary of how to write a for statement that repeats processing a specified number of times with ShellScript Bash

Example of writing

--The following is an example of a for statement that repeats processing a specified number of times. --((i = 0; i <specified number of times; i ++)) is ((i starts from 0; processing ends when this number is reached; i plus 1 for each processing))) It means

#!/bin/bash

for ((i=0; i<Specified number of times; i++)); do
Processing that you want to repeat the specified number of times
done

More specific example of writing

--The output of the expected value is described below.

*
**
***
****
*****

--The process for outputting the expected value described above is described below.

#!/bin/bash

FOO_1="*"
FOO_2="*"
for ((i=0; i<5; i++)); do
  echo "${FOO_1}"
  FOO_1="${FOO_1}""${FOO_2}"
done

Recommended Posts

How to write a ShellScript Bash for statement
How to write a ShellScript bash case statement
How to write a Python class
How to define multiple variables in a python for statement
How to write a test for processing that uses BigQuery
Qiita (1) How to write a code name
[Introduction to Python] How to use the in operator in a for statement?
How to create a shortcut command for LINUX
How to write a named tuple document in 2020
[Go] How to write or call a function
[Introduction to Python] How to get the index of data with a for statement
How to write a GUI using the maya command
[Go] How to create a custom error for Sentry
How to write a list / dictionary type of Python3
[Python] How to write a docstring that conforms to PEP8
How to create a local repository for Linux OS
Convenient to use matplotlib subplots in a for statement
How to build a development environment for TensorFlow (1.0.0) (Mac)
When you want to plt.save in a for statement
Compare how to write processing for lists by language
[Introduction to Python] How to write repetitive statements using for statements
XPath Basics (2) -How to write XPath
How to call a function
How to hack a terminal
How to manage a README for both github and PyPI
[Python] How to write an if statement in one sentence.
How to make a Python package (written for an intern)
How to substitute a numerical value for a partial match (Note 1)
I'll never forget how to write a shell script, don't forget! !!
I didn't know how to use the [python] for statement
How to create a SAS token for Azure IoT Hub
How to write a metaclass that supports both python2 and python3
How to make a Japanese-English translation
How to put a symbolic link
[For non-programmers] How to walk Kaggle
How to write soberly in pandas
Flask reuse How to write html
How to make a slack bot
How to create a Conda package
Write standard output to a file
How to make a crawler --Advanced
How to make a recursive function
How to create a virtual bridge
How to make a deadman's switch
How to create a Dockerfile (basic)
[Blender] How to make a Blender plugin
How to delete a Docker container
How to write Docker base image
How to write Django1.9 environment-independent wsgi.py
How to make a crawler --Basic
Notes on how to write requirements.txt
How to create a config file
How to execute the sed command many times using the for statement
[Introduction to Python] How to output a character string in a Print statement
How to create a label (mask) for segmentation with labelme (semantic segmentation mask)
Difference in how to write if statement between ruby ​​and python
Change the bash prompt to a simple color for easy viewing
[For beginners] How to register a library created in Python in PyPI
Spigot (Paper) Introduction to how to make a plug-in for 2020 # 01 (Environment construction)
How to make a unit test Part.1 Design pattern for introduction
How to write a docstring to create a named tuple document with sphinx