Quantcast
Channel: bitNixBlog - bash programming
Viewing all articles
Browse latest Browse all 3

Substring Replace Strings In A Filename

$
0
0

This nested for loop substring replaces two parts of the filename GagHstqLEOlv5GU5kEDXmmpAoGQ=257-234.msg1. The script was used to restore missing blobs found in a mailbox backup to the live mailstore.


for d in $(find -type d)
do
  for f in $(ls $d)
  do
    f1=${f/*=}
    f2=${f1/msg*/msg}
    echo "mv -f $d/$f $d/$f2"
  done
done

This site was helpful for figuring this out:
http://tldp.org/LDP/abs/html/string-manipulation.html


Viewing all articles
Browse latest Browse all 3

Latest Images

Trending Articles





Latest Images