Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie

Regular expression help

  • 31-10-2003 10:11AM
    #1
    Registered Users, Registered Users 2 Posts: 2,045 ✭✭✭


    Hi,

    I need help constructing a script that will do the following -

    1. find all filenames that begin with 6 characters (alphanumeric) followed by a '-' AND that end in .jpg.

    2. then I need to rename each of the files so that the first '-' is replaced by a '*' and all remaining '-' are replaced by a space ' '.

    I'm running OSX using the t shell.

    Cheers.

    Michael


Comments

  • Closed Accounts Posts: 85 ✭✭Delboy79


    Is this homework ???


  • Moderators, Arts Moderators Posts: 36,138 Mod ✭✭✭✭pickarooney


    Try this:

    ls [0-Z][0-Z][0-Z][0-Z][0-Z][0-Z]-*.jpg|while read i
    do
    echo $i|sed s/-/*/|sed s'/-/ /'g
    done


  • Closed Accounts Posts: 484 ✭✭ssh


    [0-Z][0-Z][0-Z][0-Z][0-Z][0-Z]-*.jpg

    Should that not be a "-.*.jpg"

    That would only match a file ending in any number of '-'s


Advertisement