2.查看对象文件是否存在
如果存在目录,先找到目录,然后查找是否存在test3文件。
如果存在添加date到test3文件中去。否则创建新文件。
[grid@node1 u01]$ cat test3
#!/bin/bash
if [ -e /u01 ]
then
echo "OK,on the directory,now let's check the file"
if [ -e /u01/test1 ]
then
echo "Appending date to existing file "
date >> /u01/test1
else
echo "Creating new file "
date > /u01/test1
fi
else
echo "Sorry,you don't have the directory"
fi
[grid@node1 u01]$ ./test3
OK,on the directory,now let's check the file
Appending date to existing file
[grid@node1 u01]$ cat test1
#!/bin/bash
testuser=oracle
if [ $USER = $testuser ]
then
echo "Welcome $testuser"
else
echo "You are not the user"
fi
Fri Jan 8 08:36:45 EST 2016
|