Advertisement
Help Keep Boards Alive. Support us by going ad free today. See here: https://subscriptions.boards.ie/.
https://www.boards.ie/group/1878-subscribers-forum

Private Group for paid up members of Boards.ie. Join the club.
Hi all, please see this major site announcement: https://www.boards.ie/discussion/2058427594/boards-ie-2026

Regular expression help

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


    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,278 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