[Linux] Shell Script ๊ธฐ์ด ๋ฌธ๋ฒ

ยท
Linux
Shell Script๋?Unix๋ Linux ๋๋ POSIX Portable Operating System Interface๋ฅผ ์ง์ํ๋ ์ด์์ฒด์ ์ธ macOS ๋ฑ์์ ์ผ๋ฐ์ ์ผ๋ก ์ฌ์ฉํ๋ ๋ช
๋ น์ด๋ค๊ณผ if, for์ ๊ฐ์ ํ๋ก๊ทธ๋๋ฐ์ ์ธ ์์๋ก ์ด๋ฃจ์ด์ง ์ธํฐํ๋ฆฌํฐ ๊ธฐ๋ฐ์ ์คํฌ๋ฆฝํธ ์ธ์ด.Shell Script ์์ฑ ๋ฐ ์คํ์ผ๋ฐ์ ์ผ๋ก ์
ธ ์คํฌ๋ฆฝํธ ํ์ผ์ ๋ง๋ค ๋๋ sh ํ์ฅ์๋ฅผ ์ฌ์ฉ. ๊ทธ๋ฆฌ๊ณ #!/bin/bash๋ฅผ ์์ํ ๋ ์์ฑํ์ฌ ์
ธ ์คํฌ๋ฆฝํธ์์ ๋ช
์.Shell Script ์คํํ๋ ๋ฐฉ๋ฒ์ 2๊ฐ์ง. ์ฒซ๋ฒ์งธ๋ sh ๋ช
๋ น์ด๋ฅผ ์ด์ฉํ์ฌ ์คํํ๋ ๋ฐฉ๋ฒ.$ sh myshell.sh๋ ๋ฒ์งธ ๋ฐฉ๋ฒ์ ์์ฑํ ์คํฌ๋ฆฝํธ์ ์คํ ๊ถํ์ ์ฃผ๊ณ ์ง์ ์คํฌ๋ฆฝํธ๋ฅผ ์คํํ๋ ๋ฐฉ๋ฒ.$ chmod +x myshell.sh$ ./myshell..