Page 2 of 2 FirstFirst 12
Results 11 to 12 of 12

Thread: Simple bash script: move by file extension.

  1. #11
    Join Date
    Nov 2011
    Location
    /dev/root
    Beans
    Hidden!

    Re: Simple bash script: move by file extension.

    Quote Originally Posted by sisco311 View Post
    `bash script' will run the script in a subshell where extglob is not enabled. You have to enable it in your script:

    Code:
    shopt -s extglob
    commmand *+(whatever)
    The `source' command or the dot (`.') command will run the commands from the script in the current shell.
    Thank you

  2. #12
    Join Date
    Jul 2011
    Beans
    34

    Re: Simple bash script: move by file extension.

    Setting the shell options to extended fixed it the way i chose to do it, i found that method in the book i'm reading right now and i missed that i had to enable extglob.

    Quote Originally Posted by sisco311 View Post
    If you want to use extended globs, you have to enable them:
    Code:
    shopt -s extglob
    And of course using the standard globbings worked just fine aswell, thanks for the tip

    Quote Originally Posted by Vaphell View Post
    why don't you use standard globs

    Code:
    mv *.jpg *.jpeg *.gif *.png ./pictures
    or
    Code:
    mv *.{jpg,jpeg,gif,png} ./pictures

Page 2 of 2 FirstFirst 12

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •