![]() |
|
|
|
|
|||||||
| Forums | Portal | Register | Rules & FAQ | Contribute | Members List | Arcade | 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 here. |
|
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Getting yesterday DATE | osymad | Shell Programming and Scripting | 16 | 06-06-2008 05:46 AM |
| Yesterday in i.e. May 09 and 05/09 format | Daniel Gate | Shell Programming and Scripting | 3 | 05-20-2008 01:59 PM |
| yesterday | Tlg13team | Shell Programming and Scripting | 0 | 02-27-2008 12:02 AM |
| How to show yesterday date | wind_n_cloud | Shell Programming and Scripting | 1 | 02-16-2005 06:51 PM |
| minor issue on question that i had posted !! | moxxx68 | Post Here to Contact Site Administrators and Moderators | 4 | 10-23-2004 01:51 PM |
|
|
LinkBack | Thread Tools | Display Modes |
|
|||
|
Was wondering if it was too stupid and got deleted? Because it's gone now from the board.
I was asking about For Loops ----? #!/usr/bin/bash bank=`cat /export/home/usr/banklist.txt` cdir=`cat /export/home/usr/mountlist.txt` for d in $cdir do ls -l /apps/data/custdata/$d/$i/incoming/ ls -l /apps/data/custdata/$d/$i/outgoing/ for d in $bank do ls -l /apps/data/custdata/$d/$i/incoming/ ls -l /apps/data/custdata/$d/$i/outgoing/ done; done; The question was asking how to fill in the variables from two different lists of files and when they match peform an action ls -ltr for example? If this gets deleted it must mean I need to go to the Unix for dummies thread? Last edited by xgringo; 12-18-2007 at 12:18 PM. |
| Forum Sponsor | ||
|
|
|
|||
|
Ok well not sure I have one list say
lisa a 1 2 3 4 list b d e f g So I need something like if $a and $b exist at the same time, then do ls -l /apps/data/custdata/$a/$b/incoming/ ls -l /apps/data/custdata/$a/$b/outgoing/ The problem being soemtimes there will be an /apps/data/custdata/1/d/incoming/ directory but there will be also times when an /apps/data/custdata/3/f/incoming/ won't exist --- I want to do an ls on the two combos from the two different list files that match? |
|
||||
|
Try something like:
Code:
for a in 1 2 3 4 ; do
for b in d e f g ; do
if [[ -d /apps/data/custdata/$a/$b/incoming/ ]] ; then
ls -l /apps/data/custdata/$a/$b/incoming/
fi
if [[ -d /apps/data/custdata/$a/$b/outgoing/ ]] ; then
ls -l /apps/data/custdata/$a/$b/outgoing/
fi
done
done
|
|
|||
|
Quote:
and I got data like this + [[ -d /apps/data/custdata/tmp2/noma/outgoing/ ]] + [[ -d /apps/data/custdata/tmp2/lima/incoming/ ]] + [[ -d /apps/data/custdata/tmp2/urma/outgoing/ ]] + [[ -d /apps/data/custdata/tmp2/filoma/incoming/ ]] + [[ -d /apps/data/custdata/tmp2/triloma/outgoing/ ]] + [[ -d /apps/data/custdata/tmp2/cbass/incoming/ ]] + [[ -d /apps/data/custdata/tmp2/estate/outgoing/ ]] + [[ -d /apps/data/custdata/tmp2/fondu/incoming/ ]] + [[ -d /apps/data/custdata/tmp2/kingson/outgoing/ ]] + [[ -d /apps/data/custdata/tmp2/lupra/incoming/ ]] + [[ -d /apps/data/custdata/tmp2/jag/outgoing/ ]] + [[ -d /apps/data/custdata/tmp2/tyson/incoming So it looks like it passed the if statement but doesn't get a + for the ls ? |