需要 cut/awk 脚本来截断“/branches/testbranch/”并获取文件的目录路径但忽略目录
/branches/testbranch/abc/efg/hij/klm/casestudy
/branches/testbranch/abc/efg/hij/klm/casestudy/testBlocksCargo.java
/branches/testbranch/abc/efg/hij/klm/casestudy/testBlocksCollection.java
/branches/testbranch/abc/efg/hij/klm/casestudy/testBlocksPrimaryKey.java
/branches/testbranch/claims/returns/policy/checkmate/casestudy
/branches/testbranch/claims/returns/policy/checkmate/casestudy/testBlocksGenDAO.java
/branches/testbranch/claims/returns/policy/checkmate/casestudy/testIndexGenDAO.java
期望的输出:
abc/efg/hij/klm/casestudy
abc/efg/hij/klm/casestudy
abc/efg/hij/klm/casestudy
claims/returns/policy/checkmate/casestudy
claims/returns/policy/checkmate/casestudy
我的脚本:
while read line
do
change_directory=`echo "$line" | awk -F'/[^/]*$' '{sub("/branches/testbranch/","",$1)}$0=$1'`
echo "$change_directory"
done <"test
脚本输出:
abc/efg/hij/klm
abc/efg/hij/klm/casestudy
abc/efg/hij/klm/casestudy
abc/efg/hij/klm/casestudy
claims/returns/policy/checkmate
claims/returns/policy/checkmate/casestudy
claims/returns/policy/checkmate/casestudy
顺便说一句,目录和分支详细信息发生了变化