![]() |
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.
|
|
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 |
| Moving files not directory. | senthil_is | Shell Programming and Scripting | 1 | 05-09-2008 01:21 AM |
| Getting unusual error - moving files to another directory | aismann | Shell Programming and Scripting | 4 | 12-21-2007 03:29 AM |
| How to Compress files before moving them in a directory | godalle | Shell Programming and Scripting | 3 | 11-10-2005 11:59 AM |
| moving files from a unix directory to a windows directory | gleads | UNIX for Dummies Questions & Answers | 2 | 08-29-2002 08:42 PM |
| Report with mutiple files. | Cameron | Shell Programming and Scripting | 4 | 01-28-2002 08:44 PM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
Mutiple For loops - moving files to another directory
I need to clean out some application subdirectories from backup scripts we used to rename to various backup extensions just in case the script failed in production and we need to rollback. I will be moving these old scripts to a staging directory and then removing them after 30 days (I have the find command for removing scripts after so many days).
The subdirectories would be application directories in a specified place with another subdirectory that would contain the scripts, both of which I have to loop through, they will look like this: /dir/dir/*/scripts (the ‘*’ is the application subdirectory that I will have to loop through, like /dir/dir/finance/scripts or /dir/dir/admin/scripts for example – there are around 15 of them or so). So I have to loop through the application directories, go into their scripts directory, and loop through the list of files to find any backup files and move them to a new staging directory like (/dir/dir/staging). These scripts could have one of a variety of possible extensions: kshO, .bkp, .bkup, .OLD, or _OLD The environment is KSH. My knowledge of Unix at this point is limited to simple loops, so I’m not sure how to do 2 loops in 2 different places yet - could it be as simple as nesting a for loop in another for loop? |
|
||||
|
Mutiple For loops - moving files to another directory
I tried it as you stated and it came back with a syntax error of '|' unexpected. I then tried it with ||, and [[ ]]. Using your logic, I will research some more. If you have any other ideas, I'm appreciative!
|
|
||||
|
Mutiple For loops - moving files to another directory
Hey ShellLife,
That last one seemed to work better, I got some results back, but not quite as I expected, but getting closer ! At some point, I will have to exchange the last '*' for the directory "scripts" because I will be searching only the scripts folder in each application directory (/dir/dir/*/scripts), but for now, I'm just trying to work with the code you're suggesting. Funny, when I tried it several more times, I didn't get anything back (I checked my syntax over and over again). At any rate, this is what it gave me:ksh[3]: mExt/dir/dir/admin/data: not found ksh[3]: mExt/dir/dir/admin/scripts: not found ksh[3]: mExt/dir/dir/finance/data: not found ksh[3]: mExt/dir/dir/finance/scripts: not found So it seems to be finding the folders, but not the stuff listed in the case statement, and it seems to be tacking on mExt to the end. I like the idea of the case statement though, it seems to be helping. I'll keep playing with it... |
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|