1、判断目录是否存在
shell :
if [ ! -d $SYNCDIR ]; then
mkdir -p $SYNCDIR
Python:
import os
os.path.exists(directory) #如果目录不存在就返回False
2、获取当前路径的目录
shell
#!/bin/sh
PATH_DIR=$(dirname "$PATH") || exit 1
echo $PATH_DIR
python
import sys,os
PATH_DIR=os.path.dirname($PATH)
Python中的目录处理: http://hi.baidu.com/fishhatta/blog/item/d16bdbed7b26a0e4cf1b3e03.html
转载于:https://blog.51cto.com/jason2016/415956