일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | 5 | 6 | 7 |
8 | 9 | 10 | 11 | 12 | 13 | 14 |
15 | 16 | 17 | 18 | 19 | 20 | 21 |
22 | 23 | 24 | 25 | 26 | 27 | 28 |
29 | 30 | 31 |
- docker
- CentOS
- Audit Log
- Elasticsearch
- Elk
- centos 7.5
- Chrome
- 디렉토리
- audit
- Shell
- syslog
- 빅데이터
- Kubernetes
- yum
- GNOME
- rsyslog
- bash
- PostgreSQL
- JSON
- 크롬
- C
- RHEL
- log
- K8S
- GPU
- 파이썬
- Linux
- zabbix
- 서울시민카드
- Python
- Today
- Total
Sysops Notepad
[Linux] bash if 파일 체크 관련 옵션 본문
#!/bin/bash
file=./file
if [ -e "$file" ]; then
echo "File exists"
else
echo "File does not exist"
fi
#!/bin/bash
file=./file
if [ ! -e "$file" ]; then
echo "File does not exist"
else
echo "File exists"
fi
-b filename - Block special file
-c filename - Special character file
-d directoryname - Check for directory Existence
-e filename - Check for file existence, regardless of type (node, directory, socket, etc.)
-f filename - Check for regular file existence not a directory
-G filename - Check if file exists and is owned by effective group ID
-G filename set-group-id - True if file exists and is set-group-id
-k filename - Sticky bit
-L filename - Symbolic link
-O filename - True if file exists and is owned by the effective user id
-r filename - Check if file is a readable
-S filename - Check if file is socket
-s filename - Check if file is nonzero size
-u filename - Check if file set-user-id bit is set
-w filename - Check if file is writable
-x filename - Check if file is executable
출처 : https://stackoverflow.com/questions/638975/how-do-i-tell-if-a-regular-file-does-not-exist-in-bash
'업무 > etc' 카테고리의 다른 글
[Linux] 서버 호스트명(hostname) 확인 및 변경 (0) | 2021.11.15 |
---|---|
nginx response 못 받고 끊어질때 조치 방법 (0) | 2021.11.09 |
[WINDOWS] 윈도우 10 실행중인 서비스(service),프로세스(process) 및 포트(port) 확인 방법 (0) | 2021.06.13 |
[Linux] 리눅스 seq 명령어 사용법 (0) | 2021.05.07 |
Online XML Viewer , Online JSON Viewer등 다양한 기능을 제공하는 codebeautify (0) | 2021.04.22 |