'IF'에 해당되는 글 3건

  1. 2021.07.27 [Bash] 문자열 비교 예제
  2. 2020.04.07 [Shell] Bash read, if then fi
  3. 2017.11.22 [Bash] for loop range and if condition

[Bash] 문자열 비교 예제

ITWeb/개발일반 2021. 7. 27. 08:11
#!/bin/bash

retry='retry'

if [ $retry = "retry" ]; then
  echo 'true - 1'
fi

if [[ $retry = "retry" ]]; then
  echo 'true - 2'
fi

if [[ "$retry" = "retry" ]]; then
  echo 'true - 3'
fi

세 예제 다 true 리턴 합니다.

:

[Shell] Bash read, if then fi

ITWeb/개발일반 2020. 4. 7. 20:07
#!/usr/bin/env bash

pwd

echo "Are you sure current directory? (Y/N)"
read answer

if [ "$answer" == "y" ] || [ "$answer" == "Y" ]
then
  echo "Yes!!"
fi

echo "done!!"
#!/usr/bin/env bash

pwd

echo "Are you sure current directory? (Y/N)"
read ans
answer=`echo $ans| tr a-z A-Z`

if [ "$answer" == "Y" ]
then
  echo "Yes!!"
fi

echo "done!!"

 

:

[Bash] for loop range and if condition

ITWeb/개발일반 2017. 11. 22. 11:16

이런 간단한것도 매번 생각이 나지 않아서 기록해 봅니다.


$ for i in {1..10}

do

s3cmd get s3://part-$i

if [ $i -gt 9 ]

then

break

fi

done


: