Re: C-Shell: How to append to filename?
- From: Billy Patton <bpatton@xxxxxx>
- Date: Fri, 10 Aug 2007 12:58:43 -0500
Andrew wrote:
Hello, I am writing my first (C-Shell) UNIX script and I would like to
know how to rename each file in a directory by appending a _new to it.
For example, if I have in a directory the files:
apple
banana
catfish
Then I want, after program execution, for them to be:
apple_new
banana_new
catfish_new
So far I have this:
-
#!/bin/csh
foreach filename (`ls`)
mv $filename ????;
end
-
I don't know what to put in the ????, I'm not sure how to do dynamic
variable names. If anyone could let me know, I would thank them.
Regards!
foreach filename (`ls`)
mv $filename ${filename}_new;
end
BTW, use the fully qualified path for mv and ls. Any user can set an alias to completely change the basic function of any command.
Been bit by this one many times :)
.
- References:
- C-Shell: How to append to filename?
- From: Andrew
- C-Shell: How to append to filename?
- Prev by Date: Re: rcp : permission denied
- Next by Date: Help!
- Previous by thread: Re: C-Shell: How to append to filename?
- Next by thread: rcp : permission denied
- Index(es):
Relevant Pages
|