Advertisement
Help Keep Boards Alive. Support us by going ad free today. See here: https://subscriptions.boards.ie/.
If we do not hit our goal we will be forced to close the site.

Current status: https://keepboardsalive.com/

Annual subs are best for most impact. If you are still undecided on going Ad Free - you can also donate using the Paypal Donate option. All contribution helps. Thank you.
https://www.boards.ie/group/1878-subscribers-forum

Private Group for paid up members of Boards.ie. Join the club.

Quick help needed with a Bash script...

  • 07-05-2005 02:07PM
    #1
    Closed Accounts Posts: 4,763 ✭✭✭


    I want to make a batch mover for files, along these lines, for updating my config files in Gentoo after a big emerge, after doing a find for them.
    mv /etc/.crap.<filename> /etc/<filename>
    

    I've no problems with a small script to to find all the files that need updating, but how can I direct it to search for files based on one part of its name and then alter them based on another part?


Comments

  • Registered Users, Registered Users 2, Paid Member Posts: 748 ✭✭✭Dero


    cd /etc
    for i in .crap.*
    do
    mv $i ${i##.crap.}
    done
    

    Edit: Also, read this. Very useful reference.


  • Closed Accounts Posts: 4,763 ✭✭✭Fenster


    Thanks for the link, some nice reading there, even if it is a wee bit too big to be all printed out :(


Advertisement