Results 1 to 4 of 4
  1. #1
    Join Date
    Feb 2004
    Posts
    143

    Unanswered: URGENT...help with mv

    Hi,
    I have files in my directory which is named like

    aaa.sh_save
    bbb.sh_save
    ccc.sh_save
    ddd.ctl_save ...( plus there are many more like this.)


    I wanted to rename all of these scripts to ...

    aaa.sh
    bbb.sh
    ccc.sh
    ddd.ctl


    In other words, the _save should be removed from the file names. How do I acheive this ? This should also affect all files lying in the sub-directories too.... from my current directory it should change all files plus all sub-direcotory files too...
    Thanks

  2. #2
    Join Date
    Apr 2004
    Location
    Boston, MA
    Posts
    325
    #!/bin/ksh
    find . -name '*_save' | while read file
    do
    mv $file ${file%%_save}
    done;

  3. #3
    Join Date
    Feb 2004
    Posts
    143
    Thanks a lot...worked great...

    Can I also ask you a question on this solution. How can I find help on the meaning of %% (just for my fyi to know how it does things and other options)..

  4. #4
    Join Date
    Apr 2004
    Location
    Boston, MA
    Posts
    325
    do 'man ksh' and search for 'Parameter Expansion'

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •