![]() |
|
|
|
|
|||||||
| Forums | Portal | Register | Forum 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 |
| Counting files in one directory | matrixtlm | UNIX for Dummies Questions & Answers | 10 | 06-15-2007 04:14 PM |
| Counting number of files in a directory | iamalex | UNIX for Dummies Questions & Answers | 2 | 09-05-2005 07:13 AM |
| List files that do not match the search pattern | olapxpert | UNIX for Dummies Questions & Answers | 7 | 04-14-2005 12:49 PM |
| List files that do not match the search pattern | olapxpert | IP Networking | 1 | 04-14-2005 11:37 AM |
| rm files in a directory, looping, counting, then exit | JporterFDX | Shell Programming and Scripting | 6 | 07-18-2002 05:56 AM |
|
|
Submit Tools | LinkBack | Thread Tools | Display Modes |
|
|||
|
Glenn,
If I need to through out an error , how should I set it Iam doing like this but it's not throughing error. #!/bin/ksh dir=/biddf/ab6498/dev/ctl export dir # set -x myfilepattern=$@ integer filecount=0 for file in $myfilepattern; do filecount=$filecount+1 done if (( $filecount == 10 )); then exit 0 else exit 1 echo failure fi |
| Forum Sponsor | ||
|
|
|
|||
|
Glenn,
Thank you very much it's throughing an error now. But if I don't need to pass the whole name of the file but just BARE01_DLY. some thing like this: check20.sh BARE01_DLY But it has to check whether 20 files are present for that day or not? I am using the code below. It's not working. What's wrong in this? #!/bin/ksh myfilepattern=$@ integer filecount=0 for file in $myfilepattern_$(date +%Y%m%d); do filecount=$filecount+1 done if (( $filecount == 20 )); then exit 0 else exit 1 fi Please suggest |
|
|||
|
Glenn,
The code I modifed like this; #!/bin/ksh dir=/biddf/ab6498/dev/ctl export dir set -x myfilepattern=$@ integer filecount=0 for file in $myfilepattern_???_(date +%Y%m%d); do filecount=$filecount+1 done if (( $filecount == 10 )); then print "success" exit 0 else print "failure" exit 1 fi Please suggest |
|
|||
|
Glenn,
I removed the braces in between date field but i am surprised how the value of filecount is 2 here. See the debug output once I remove the braces between date field in the script. myfilepattern=BARE01_DLY + typeset -i filecount=0 + filecount=0+1 + filecount=1+1 + let 2 == 10 + print failure failure + exit 1 Here is the script; #!/bin/ksh dir=/biddf/ab6498/dev/ctl export dir set -x myfilepattern=$@ integer filecount=0 for file in $myfilepattern_???_date +%Y%m%d ; do filecount=$filecount+1 done if (( $filecount == 10 )); then print "success" exit 0 else print "failure" exit 1 fi |
|
|||
|
Debug doesn't match script logic
I have a script like this below. I am calling the script like this script1.ksh BARE01_DLY The script looks in the directory for named files BARE01_DLY_???_YYYYMMDD. The YYYYMMDD signify todays date when the script ran. It checks whether they are 10 files with that pattern for today and if they are then it shows succes otherwise failure. But in the directory I have only one file with name BARE01_DLY_MKT_20060720. But after I run the script in debug mode the output shows like it has 2 files with that name. Please see belwo for output.
myfilepattern=BARE01_DLY + typeset -i filecount=0 + filecount=0+1 + filecount=1+1 + let 2 == 10 + print failure failure + exit 1 Here it shows 2==10 but I have only one file for that day. So where am i going wrong. Please suggest. Below is the script. Code:
#!/bin/ksh dir=/biddf/ab6498/dev/ctl export dir set -x myfilepattern=$@ integer filecount=0 for file in $myfilepattern_???_date +%Y%m%d ; do filecount=$filecount+1 done if (( $filecount == 10 )); then print "success" exit 0 else print "failure" exit 1 fi Last edited by reborg; 07-20-2006 at 05:27 PM. |
|||
| Google The UNIX and Linux Forums |