Type the following commands:
$ [ -f /etc/passwd ] && echo "File exists" || echo "File does not exists"Find out if directory /var/logs exists or not
$ [ -f /tmp/fileonetwo ] && echo "File exists" || echo "File does not exists"
Type the following commands:
$ [ -d /var/logs ] && echo "Directory exists" || echo "Directory does not exists"다음과 같이 짤수 있음.
$ [ -d /dumper/fack ] && echo "Directory exists" || echo "Directory does not exists"
#!/bin/bash키워드 : check, shell
FILE=$1
if [ -f $FILE ];
then
echo "File $FILE exists"else
echo "File $FILE does not exists"fi
레퍼런스 : Linux/UNIX: Find Out If File Exists With Conditional Expressions
No comments:
Post a Comment