Ask a Question related to AIX, Design and Development.
-
sengstock3 #1
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
-
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... -
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? -
File::Copy
Anyone know how to get File::Copy module to keep file permissions when it copies from one location to another? Thanks -
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... -
Wildcards in rename()?
Hi all! Do any of you know if wildcards are accepted when calling rename() function? Thanks/Alvaro -
Alois Steindl #2
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
-
Todd H. #3
Re: File copy wildcards
sengstock3 <member25238@dbforums.com> writes:
#!/bin/ksh> 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.
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
-
Nicholas Dronen #4
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
-
Michael Plutt #5
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...to> 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> 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
-
Nicholas Dronen #6
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...MP> to>> 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 scriptMP> Hello All,>> 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> 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
-
Michael Plutt #7
Re: File copy wildcards
"Nicholas Dronen" <ndronen@io.frii.com> wrote in message
news:3f666633$0$62079$75868355@news.frii.net...script>
> 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 simplegg0915.old> 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>> >>
> >> 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



Reply With Quote

