shell - Renaming directories inside the tar.gz while extracting the tar in linux -
i have tarball index.tar.gz. inside have directories this
index1/db_newtime_oldtime_0
index1/db_newtime_oldtime_1
index1/db_newtime_oldtime_2
index2/db_newtime_oldtime_0
index2/db_newtime_oldtime_1
index2/db_newtime_oldtime_2
while extracting tar file, want add 99 numeric value @ end of db directory name. after extraction directory structure should this
index1/db_newtime_oldtime_99
index1/db_newtime_oldtime_100
index1/db_newtime_oldtime_101
index2/db_newtime_oldtime_99
index2/db_newtime_oldtime_100
index2/db_newtime_oldtime_101
so possible rename using shell script ?
after extracting tar ball can rename each of directory names inside index*/
... can use loop :
for in $(\ls -d index*/*); dst=$(echo "$i" | sed -e 's/oldtime_/oldtime_ /g' | awk '{print $1$2+99}'); mv "$i" "$dst"; done
Comments
Post a Comment