Bash 팁

Kangyeol Kim·2023년 7월 1일
0
# 할당
hello="A B  C   D"

echo $hello
echo ${hello} # 위와 똑같습니다.
echo "$hello"
> A B  C   D

echo '$hello'
> $hello
echo '${hello}'
> ${hello}
# 조건
if [ condition1 ]
then
  if [ condition2 ]
  then
    do-something  # "conditino1"과 "condition2"가 모두 참일 경우에만
  fi
fi
# 따옴표로 묶인 전체 '목록'은 한 개의 변수를 만들어 냅니다.
for planet in "Mercury Venus Earth Mars Jupiter Saturn Uranus Neptune Pluto"
do
  echo $planet
done

# $PWD(현재 디렉토리)의 모든 파일을 나열.
for file in *
do
  ls -l "$file"  
done
# find - 찾아낸 각각의 파일에 대해 COMMAND를 실행합니다.
find . -type f -name '*.txt' | sort
  • 계속 이어서 추가할 예정

참고

profile
Ph.D. Student @ KAIST / Co-Founder @ Letsur

0개의 댓글