Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
需要获取路径的一部分,例如“/home/server/folder1/rev.1111/bin” 需要的部分是“rev.1111” 我会尝试通过 PWD 和 grep 命令解析,但我是 linux 上的新手,我不能这样做。
pwd | awk -F/ '{print $(NF-1)}'
使用 basename 和 dirname 命令:
basename $(dirname $(pwd))