获取路径的各种相关方法:

获取文件名:

basename /home/cuizhiliang344/note.txt

note.txt


获取目录:

dirname /home/cuizhiliang344/note.txt

/home/cuizhiliang344


通过一个文件获取全路径


方法一:

readlink -f  note.txt

/home/cuizhiliang344/note.txt

方法二:

python -c 'import os; print(os.path.abspath("note.txt"))'

方法三:

ls $PWD/note.txt