Quick hack to rename all prefixed files in a directory to a new prefix

loghyr:xxx thomas$ ls -1 pnfswars* | sed ‘s/\(pnfswars\)\(.*\)/mv \1\2 lnfsreg\2/’ | sh

And to do this as a script:

loghyr:xxx thomas$ more reprefix.sh
#! /bin/sh
ls -1 ${1}* | sed ‘s/\(‘${1}’\)\(.*\)/mv \1\2 ‘${2}’\2/’ | sh

Leave a Reply