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
Hi there,
There is an issue with role permissions that is being worked on at the moment.
If you are having trouble with access or permissions on regional forums please post here to get access: https://www.boards.ie/discussion/2058365403/you-do-not-have-permission-for-that#latest

Regular expression help

  • 31-10-2003 9:11am
    #1
    Registered Users, Registered Users 2 Posts: 2,047 ✭✭✭


    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: 35,731 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