문서의 선택한 두 판 사이의 차이를 보여줍니다.
| 양쪽 이전 판 이전 판 다음 판 | 이전 판 | ||
|
linux:shell_script [2021/05/18 16:25] kwon37xi |
linux:shell_script [2024/01/19 08:09] (현재) kwon37xi |
||
|---|---|---|---|
| 줄 4: | 줄 4: | ||
| * [[linux: | * [[linux: | ||
| * [[linux: | * [[linux: | ||
| + | |||
| + | ===== 인자 갯수 검사 Argument count ===== | ||
| + | * '' | ||
| + | <code sh> | ||
| + | if [ " | ||
| + | echo " | ||
| + | fi | ||
| + | </ | ||
| ===== pipe 출력 결과를 그대로 실행하기 ===== | ===== pipe 출력 결과를 그대로 실행하기 ===== | ||
| 줄 28: | 줄 36: | ||
| * [[https:// | * [[https:// | ||
| - | ===== 참조 ===== | + | <code sh> |
| + | find . -type f | | ||
| + | while read -r line | ||
| + | do | ||
| + | echo " | ||
| + | done | ||
| + | # one liner | ||
| + | find . -type f | while read -r line; do echo " | ||
| + | |||
| + | |||
| + | # 혹은 | ||
| + | |||
| + | while read -r line | ||
| + | do | ||
| + | echo " | ||
| + | done < <(find . -type f) | ||
| + | </ | ||
| + | * [[http:// | ||
| + | |||
| + | ===== 실패시 fallback 처리 ===== | ||
| + | * '' | ||
| + | |||
| + | <code sh> | ||
| + | # curl 명령 실패시에 " | ||
| + | TEST_RESULT=$(curl -Ss https:// | ||
| + | </ | ||
| + | |||
| + | ===== 명령의 존재 검사 ===== | ||
| + | * '' | ||
| + | |||
| + | <code sh> | ||
| + | command -v < | ||
| + | |||
| + | if ! command -v < | ||
| + | then | ||
| + | echo "< | ||
| + | exit | ||
| + | fi | ||
| + | </ | ||
| + | * '' | ||
| + | * '' | ||
| + | <code sh> | ||
| + | if hash gdate 2>/ | ||
| + | gdate " | ||
| + | else | ||
| + | date " | ||
| + | fi | ||
| + | </ | ||
| + | * [[https:// | ||
| + | |||
| + | ===== 참조 ===== | ||
| + | * [[https:// | ||
| * [[https:// | * [[https:// | ||
| * [[https:// | * [[https:// | ||
| 줄 37: | 줄 96: | ||
| * [[https:// | * [[https:// | ||
| * [[https:// | * [[https:// | ||
| + | * [[https:// | ||