The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Dummies Questions & Answers
Google UNIX.COM



View Single Post in UNIX Forums - Click on the Thread or Permalink to View Entire Thread -->
  #7 (permalink)  
Old 09-22-2007
kamitsin's Avatar
kamitsin kamitsin is offline
Registered User
 

Join Date: Nov 2006
Location: /dev/null
Posts: 177
Case1: TestFish_done.txt to Test Fish Done.txt,

Code:
#!/bin/ksh
for oldfile in $(find . -name TestFish*)
do
   newfile="$(echo $oldfile | sed 's/Test/Test /g'|sed 's/\_/ /g')"
   mv "$oldfile" "$newfile"
done
Case2: FishOne_done.txt to FishOne.txt

Code:
#!/bin/ksh
for oldfile in $(find . -name FishOne*)
do
   newfile="$(echo $oldfile | sed 's/_done//g')"
   mv "$oldfile" "$newfile"
done
Reply With Quote