1 개념[ | ]
- Shell Programming / Control Statement; Flow Control Statement
- 쉘 프로그래밍 / 제어문
2 조건문[ | ]
2.1 if[ | ]
Bash
Copy
He="John Smith"
if [ "$He" = "John Smith" ]; then
echo "He is John Smith"
else
echo "He is not John Smith"
fi
# He is John Smith
Bash
Copy
He="Jane Doe"
if [ "$He" != "John Smith" ]; then
echo "He is not John Smith"
fi
# He is not John Smith
3 반복문[ | ]
3.1 for[ | ]
- 문법
Bash
Copy
for i [in LIST]
do
// Do something
done
- →LIST는 반복이 가능한 숫자, 문자열 등이 들어감
- for문 예시
Bash
Copy
#!/bin/bash
LIST=$(ls)
for i in $LIST
do
echo $i
done
- →LIST에 현재 디렉토리에서 ls명령 수행 결과값들이 들어감
- →for문에서 LIST변수 값들이 출력됨
4 같이 보기[ | ]
편집자 John Jeong Jmnote Jmnote bot
로그인하시면 댓글을 쓸 수 있습니다.
- 분류 댓글:
- Bash (3)
로또번호 생성 ―Pinkcrimson
리눅스 날짜 기준으로 파일 삭제하기 ― 백승현리눅스 날짜 기준으로 파일 삭제하기 ― Jmnote