![]() |
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here. |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Detecting incoming files without busy polling | baldyeti | Shell Programming and Scripting | 9 | 08-15-2008 12:06 PM |
| script to find the average number or files? | bbbngowc | Shell Programming and Scripting | 2 | 03-27-2008 12:57 PM |
| run a script from incoming email | jojo77 | UNIX for Dummies Questions & Answers | 7 | 02-22-2008 01:48 PM |
| find number of incoming requests to a server | laddu | UNIX for Dummies Questions & Answers | 1 | 03-10-2007 01:48 AM |
| awk script to find the number of files | uni_ajay_r | Shell Programming and Scripting | 4 | 10-31-2006 06:58 PM |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
||||
|
Script to number incoming files
Hey guys, I am working on a Cshell script and I am stuck on this one part. I need to be able to copy in files to my directory but give them different names so they don't overwrite each other. For example, my folder already contains FILE.1 I want my script to name the next file copied over FILE.2 and the next one FILE.3 and so on. It should be able to tell what files are there and named the new one the next highest value. So I have FILE.1, FILE.2, and FILE.3 in my directory now, If I copy in another file, my script should rename it FILE.4 This script has been driving me nuts all day I can't figure it out. Here is what I have so far. Thanks in advance. New code would be appreciated because I obviously have no clue what I'm doing in this piece. Code:
while (-d FILE.0)
cp -r FILE FILE.1
set ctr = 1
foreach f(*)
set var1 = 'file $f | awk '{printf "%s\n",$3}''
if ($var1 == 1) then
FILE = 'ls $f | cut -f1 -d "."'
1 = 'ls $f | awk -F "." '{printf "%s\n",$2}''
mv $f $FILE$ctr.$1
ctr = 'expr $ctr + 1'
endif
end
end
|
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|