Ask a Question related to AIX, Design and Development.

  1. #1

    Default File copy wildcards


    I have a directory with files named:



    ex0915

    dx0915

    gg0915

    ex0914

    dx0914

    gg0914



    ...etc.



    Is there a way to change them all to



    ex0915.old

    dx0915.old

    gg0915.old

    ex0914.old

    dx0914.old

    gg0914.old



    ?? can't do it with cp or rm. Anyone have ideas for a simple script to
    do this? Thanks in advance.



    -Mark


    --
    Posted via [url]http://dbforums.com[/url]
    sengstock3 Guest

  2. Similar Questions and Discussions

    1. Using wildcards in a WHERE statement
      I'm in the process of converting from Access to SQLServer and need help with using wild cards in a WHERE statement. When the following statement is...
    2. Wildcards
      Why isn't it possible to search with wildcards (like * and ?) in Acrobat 6? In Acrobat 5 it used to be possible. What is the alternative?
    3. File::Copy
      Anyone know how to get File::Copy module to keep file permissions when it copies from one location to another? Thanks
    4. Finding filenames using wildcards
      I have an interesting challenge. I have a client that is putting pictures into a single folder on the web server. The files are specific in that...
    5. Wildcards in rename()?
      Hi all! Do any of you know if wildcards are accepted when calling rename() function? Thanks/Alvaro
  3. #2

    Default Re: File copy wildcards

    Hello,
    instead telling you one solution, I would like to point you to the
    newsgroup comp.unix.questions. Especially its FAQ contains a lot of
    valuable informations.
    Alois

    --
    Alois Steindl, Tel.: +43 (1) 58801 / 32558
    Inst. for Mechanics II, Fax.: +43 (1) 58801 / 32598
    Vienna University of Technology,
    A-1040 Wiedner Hauptstr. 8-10
    Alois Steindl Guest

  4. #3

    Default Re: File copy wildcards

    sengstock3 <member25238@dbforums.com> writes:
    > I have a directory with files named:
    >
    > ex0915
    > dx0915
    > gg0915
    > ex0914
    > dx0914
    > gg0914
    > ..etc.
    >
    > Is there a way to change them all to
    >
    > ex0915.old
    > dx0915.old
    > gg0915.old
    > ex0914.old
    > dx0914.old
    > gg0914.old
    >
    > ?? can't do it with cp or rm. Anyone have ideas for a simple script to
    > do this? Thanks in advance.
    #!/bin/ksh
    for file in [a-z][xg]0[0-9][0-9][0-9][0-9]
    do
    mv $file $file.old
    done

    Caveat: untested. Probably broken, but gives you a flavor.

    --
    Todd H.
    [url]http://www.toddh.net/[/url]
    Todd H. Guest

  5. #4

    Default Re: File copy wildcards

    sengstock3 <member25238@dbforums.com> wrote:

    s> I have a directory with files named:


    s> ex0915
    s> dx0915
    s> gg0915
    s> ex0914
    s> dx0914
    s> gg0914

    s> ..etc.

    s> Is there a way to change them all to

    s> ex0915.old
    s> dx0915.old
    s> gg0915.old
    s> ex0914.old
    s> dx0914.old
    s> gg0914.old

    s> ?? can't do it with cp or rm. Anyone have ideas for a simple script to
    s> do this? Thanks in advance.

    If perl is installed on the machine, rename is probably install, too.

    $ ls
    dx0914 dx0915 ex0914 ex0915 gg0914 gg0915
    $ rename 's/$/.old/' *
    $ ls
    dx0914.old dx0915.old ex0914.old ex0915.old gg0914.old gg0915.old

    If there are files in that directory you do not wish to rename, then do
    something like:

    $ rename 's/$/.old/' [edg][xg][0-9][0-9][0-9][0-9]

    Regards,

    Nicholas

    --
    "Why shouldn't I top-post?" [url]http://www.aglami.com/tpfaq.html[/url]
    "Meanings are another story." [url]http://www.ifas.org/wa/glossolalia.html[/url]
    Nicholas Dronen Guest

  6. #5

    Default Re: File copy wildcards

    Hello All,

    I would just do the following:

    1. create a list of files:

    ls whatever > list

    Then

    for i in `cat list`
    do
    mv $i $i.old
    done

    Later
    "Nicholas Dronen" <ndronen@io.frii.com> wrote in message
    news:3f6644e4$0$62084$75868355@news.frii.net...
    > sengstock3 <member25238@dbforums.com> wrote:
    >
    > s> I have a directory with files named:
    >
    >
    > s> ex0915
    > s> dx0915
    > s> gg0915
    > s> ex0914
    > s> dx0914
    > s> gg0914
    >
    > s> ..etc.
    >
    > s> Is there a way to change them all to
    >
    > s> ex0915.old
    > s> dx0915.old
    > s> gg0915.old
    > s> ex0914.old
    > s> dx0914.old
    > s> gg0914.old
    >
    > s> ?? can't do it with cp or rm. Anyone have ideas for a simple script
    to
    > s> do this? Thanks in advance.
    >
    > If perl is installed on the machine, rename is probably install, too.
    >
    > $ ls
    > dx0914 dx0915 ex0914 ex0915 gg0914 gg0915
    > $ rename 's/$/.old/' *
    > $ ls
    > dx0914.old dx0915.old ex0914.old ex0915.old gg0914.old gg0915.old
    >
    > If there are files in that directory you do not wish to rename, then do
    > something like:
    >
    > $ rename 's/$/.old/' [edg][xg][0-9][0-9][0-9][0-9]
    >
    > Regards,
    >
    > Nicholas
    >
    > --
    > "Why shouldn't I top-post?" [url]http://www.aglami.com/tpfaq.html[/url]
    > "Meanings are another story." [url]http://www.ifas.org/wa/glossolalia.html[/url]

    Michael Plutt Guest

  7. #6

    Default Re: File copy wildcards


    Michael Plutt <mplutt@sbcglobal.net> wrote:

    Please don't top-post. It makes threads difficult to follow.

    MP> "Nicholas Dronen" <ndronen@io.frii.com> wrote in message
    MP> news:3f6644e4$0$62084$75868355@news.frii.net...
    >> sengstock3 <member25238@dbforums.com> wrote:
    >>
    >> s> I have a directory with files named:
    >>
    >>
    >> s> ex0915
    >> s> dx0915
    >> s> gg0915
    >> s> ex0914
    >> s> dx0914
    >> s> gg0914
    >>
    >> s> ..etc.
    >>
    >> s> Is there a way to change them all to
    >>
    >> s> ex0915.old
    >> s> dx0915.old
    >> s> gg0915.old
    >> s> ex0914.old
    >> s> dx0914.old
    >> s> gg0914.old
    >>
    >> s> ?? can't do it with cp or rm. Anyone have ideas for a simple script
    MP> to
    >> s> do this? Thanks in advance.
    >>
    >> If perl is installed on the machine, rename is probably install, too.
    >>
    >> $ ls
    >> dx0914 dx0915 ex0914 ex0915 gg0914 gg0915
    >> $ rename 's/$/.old/' *
    >> $ ls
    >> dx0914.old dx0915.old ex0914.old ex0915.old gg0914.old gg0915.old
    >>
    >> If there are files in that directory you do not wish to rename, then do
    >> something like:
    >>
    >> $ rename 's/$/.old/' [edg][xg][0-9][0-9][0-9][0-9]
    MP> Hello All,

    MP> I would just do the following:

    MP> 1. create a list of files:

    MP> ls whatever > list

    MP> Then

    MP> for i in `cat list`
    MP> do
    MP> mv $i $i.old
    MP> done

    A few things about this. First, the OP didn't say whether he had
    other files in the directory he didn't wish to rename. He probably
    didn't but if he doesn't know how to do this in the first place, it's
    better to protect him a bit up front. Hence the additional regular
    expressions in the responses from both me and another poster. Second,
    we all know that cat remains an expensive command to run, even with
    processor speeds as they are these days, so I always recommend using
    a shell built-in mechanism for listing files.

    $ for i in *; do mv $i $i.old; done

    No need to run both ls and cat when a simple * will do.

    Regards,

    Nicholas

    --
    "Why shouldn't I top-post?" [url]http://www.aglami.com/tpfaq.html[/url]
    "Meanings are another story." [url]http://www.ifas.org/wa/glossolalia.html[/url]
    Nicholas Dronen Guest

  8. #7

    Default Re: File copy wildcards


    "Nicholas Dronen" <ndronen@io.frii.com> wrote in message
    news:3f666633$0$62079$75868355@news.frii.net...
    >
    > Michael Plutt <mplutt@sbcglobal.net> wrote:
    >
    > Please don't top-post. It makes threads difficult to follow.
    >
    > MP> "Nicholas Dronen" <ndronen@io.frii.com> wrote in message
    > MP> news:3f6644e4$0$62084$75868355@news.frii.net...
    > >> sengstock3 <member25238@dbforums.com> wrote:
    > >>
    > >> s> I have a directory with files named:
    > >>
    > >>
    > >> s> ex0915
    > >> s> dx0915
    > >> s> gg0915
    > >> s> ex0914
    > >> s> dx0914
    > >> s> gg0914
    > >>
    > >> s> ..etc.
    > >>
    > >> s> Is there a way to change them all to
    > >>
    > >> s> ex0915.old
    > >> s> dx0915.old
    > >> s> gg0915.old
    > >> s> ex0914.old
    > >> s> dx0914.old
    > >> s> gg0914.old
    > >>
    > >> s> ?? can't do it with cp or rm. Anyone have ideas for a simple
    script
    > MP> to
    > >> s> do this? Thanks in advance.
    > >>
    > >> If perl is installed on the machine, rename is probably install, too.
    > >>
    > >> $ ls
    > >> dx0914 dx0915 ex0914 ex0915 gg0914 gg0915
    > >> $ rename 's/$/.old/' *
    > >> $ ls
    > >> dx0914.old dx0915.old ex0914.old ex0915.old gg0914.old
    gg0915.old
    > >>
    > >> If there are files in that directory you do not wish to rename, then do
    > >> something like:
    > >>
    > >> $ rename 's/$/.old/' [edg][xg][0-9][0-9][0-9][0-9]
    >
    > MP> Hello All,
    >
    > MP> I would just do the following:
    >
    > MP> 1. create a list of files:
    >
    > MP> ls whatever > list
    >
    > MP> Then
    >
    > MP> for i in `cat list`
    > MP> do
    > MP> mv $i $i.old
    > MP> done
    >
    > A few things about this. First, the OP didn't say whether he had
    > other files in the directory he didn't wish to rename. He probably
    > didn't but if he doesn't know how to do this in the first place, it's
    > better to protect him a bit up front. Hence the additional regular
    > expressions in the responses from both me and another poster. Second,
    > we all know that cat remains an expensive command to run, even with
    > processor speeds as they are these days, so I always recommend using
    > a shell built-in mechanism for listing files.
    >
    > $ for i in *; do mv $i $i.old; done
    >
    > No need to run both ls and cat when a simple * will do.
    >
    > Regards,
    >
    > Nicholas
    >
    > --
    > "Why shouldn't I top-post?" [url]http://www.aglami.com/tpfaq.html[/url]
    > "Meanings are another story." [url]http://www.ifas.org/wa/glossolalia.html[/url]

    No problem, thanks for the update


    Michael Plutt Guest

Posting Permissions

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

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139