![]() |
|
|
|
|
|||||||
| 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 | Search this Thread | Display Modes |
|
#22
|
||||
|
||||
|
threads merged, please do not start multiple threads for the same topic.
|
| Forum Sponsor | ||
|
|
|
#23
|
|||
|
|||
|
Reborg,
I am sorry for that!!! I got no answer so thought that new thread may incerase people viewing. Anyway can you help me with this please? |
|
#24
|
||||
|
||||
|
Actually that exactly the reason that it is againts the rules of these forums.
However try this: 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 |
|
#25
|
|||
|
|||
|
Reborg,
I bow to you completely. You are great. It's working great man. I will learn from this thread a lot. I will be active member from now on. Once again thank you very much. |
|
#26
|
|||
|
|||
|
Hi,
I have a problem with the script below. Basically it checks whether there is any file present with the name CARE01_DLY present for today's date in the directory /biddf/ab6498/dev/ctl and if the count =1 it says success otherwise error. But it doesn't seem to take the todays date file but checking if the file is present and saying success if the file is present with out checking for todays date. But i want the script to check for todays file only and if found it should through success otherwise error. The name of the file is sent as an argument to the script. Quote:
Quote:
Please help. |
|
#27
|
||||
|
||||
|
I found two problem in your script
$myfilepattern_???_$(date +%Y%m%d) is interpreted by the shell as ${myfilepattern_}???_$(date +%Y%m%d). You must code like this : ${myfilepattern}_???_$(date +%Y%m%d) The for statement returns the pattern itself if no file are found. You must test for that pattern. Code:
#!/bin/ksh
dir=/biddf/ab6498/dev/ctl
export dir
set -x
myfilepattern=$@
fullpattern=${my_filepattern}_???_$(date +%Y%m%d)
integer filecount=0
for file in $fullpattern ; do
[ "$file" != "$fullpattern"] && filecount=$filecount+1
done
if (( $filecount == 10 )); then
print "success"
exit 0
else
print "failure"
exit 1
fi
|
|
#28
|
|||
|
|||
|
Jean,
Thanks for the changes. But the script is still producing wrong result. There are 2 files with todays date in the directory and still it says failure. I think the main problem is pattern matching is is complaring like this: CARE01_DLY_AUS_20060724 != CARE01_DLY_???_20060724 and saying no match. So please suggest. Please see output: Quote:
|
|||
| Google The UNIX and Linux Forums |