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

Popular posts from this blog

html - How to style widget with post count different than without post count -

How to remove text and logo OR add Overflow on Android ActionBar using AppCompat on API 8? -

javascript - storing input from prompt in array and displaying the array -