LiNuX

bash shell 기초

freecatz 2019. 2. 19. 10:03

#/bin/bash

# 아래는 로그나 파일이름 등에 사용할 현재 시간 구하기.

today="$(date '+%Y.%m.%d')"
echo $today;

nowTime="$(date '+%H:%M:%S')"
echo $nowTime;



# 아래는 내용이 있는 파일을 만드는 경우. 변수 이용 가능.

cat > ./test.txt << "EOF"
This is Test Message...
EOF



# 아래는 특정  파일이 있는지 확인 하는 조건문.

if [ ! -f test ]; then
 echo "test file not fount";
fi



# 아래는 temp 디렉터리가 있는지 확인 하고 없는 경우 해당 내용 실행 하는 조건문.

if [ ! -d temp ]; then
 echo " temp Directory not fountd!";
 mkdir temp
fi