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

fine rename problem

  • 22-07-2003 4:26pm
    #1
    Registered Users, Registered Users 2 Posts: 6,265 ✭✭✭


    Evening All,
    I've got a series of files that I need to rename.
    they are in this format: ......28235.crt

    Any one know a good way to remove the ......'s from the start of the file names? The sed part of this command is showing my knowledge gap.

    for file in *.crt ; do mv $file `echo $file | sed 's///'` ; done

    Thanks,
    MiCr0


Comments

  • Closed Accounts Posts: 5,564 ✭✭✭Typedef


    for file in *
    do
            echo $file | awk '{sub(" ......","",$1); print $1}'| xargs cp $file
    done
    
    ?


  • Registered Users, Registered Users 2 Posts: 2,755 ✭✭✭niallb


    Hi MiCrO,
    indeed a fine rename problem.

    Seeing as typedef got there first with an awkism,
    I'll try the fewest keystrokes.

    This works too:
    find . -type f -ok rename \.\.\.\.\.\. '' '{}' \;
    and it looks suitably obscure. :-)
    (All quotes are single quotes - no backtick/primes)

    Once you're sure it does what you want, replace the
    -ok with -exec to lose the prompting.

    NiallB

    p.s.
    for file in *.crt ; do mv $file `echo $file | sed 's/\.\.\.\.\.\.//'` ; done
    would actually work by the way if your shell can see the files.
    You might need a for file in `/bin/ls -A *.crt`.


Advertisement