Sponsored Content
Full Discussion: call more options on if
Top Forums UNIX for Advanced & Expert Users call more options on if Post 302713627 by charli1 on Thursday 11th of October 2012 04:11:11 AM
Old 10-11-2012
Quote:
Originally Posted by Corona688
Neither * nor -e nor or work that way. You can't cram more than one file into -e, it won't work. By 'or' you probably meant '||'.

I'd try a loop instead of a huge or-statement, and put the files found into the $1 $2 ... list, then check if the first exists.

As a useful side-effect, the files being looked for will end up individually in $1, $2, ...

Code:
PREFIX="$1"
for D in "%Y-%m-%d" "%Y_%m_%d" "%Y%m%d" "%y-%m-%d-%H-%" "%y%m%d%H%M"
do
        TODAY="`date +$D`"
        set -- ${PREFIX}${TODAY}*
        # && is a short-form if/then.  If "$1" exists, then break out of the loop.
        [ -e "$1" ] && break
done

if [ -e "$1" ]
then
        echo "Found $# files for today:  $*"
else
        echo "No files found for today"
fi

Hi Corona688,
i tried to make some test with your suggestion,and it works when the file exists,
but the problem is when it doesn't exist,
because if the file doesn't exist the script is sending the mail to me with the latest file date format available, it is not sending the correct file date of the file,any ideas on how can i come around this?

Thanks in advance
.
 

7 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

cp options

Hello again, Is there an option for the cp command to overwrite existing files in the destination directory? Cheers Rob (3 Replies)
Discussion started by: milage
3 Replies

2. UNIX for Dummies Questions & Answers

options

I am just beginning to learn unix and I was wondering if there was a list of all the options somewhere on the net or hidden in the man pages? Also do options always have - and then a letter, or can it be - and a number as well? Thanks! (1 Reply)
Discussion started by: terms5
1 Replies

3. AIX

no options

Hi All, I have a situation here that's very fun... I have a system with AIX and iPlanet (sunOne) installed, when occurs an unknown event on the network the WebServer shows a thousand of CLOSE_WAIT connections and this number grows and grows until the webserver crashs. I read some documents... (2 Replies)
Discussion started by: nascimento.rp
2 Replies

4. UNIX for Advanced & Expert Users

how to differentiate system call from library call

Hi, Ho do I differentiate system call from library call? for example if I am using chmod , how do I find out if it is a system call or library call? Thanks Muru (2 Replies)
Discussion started by: muru
2 Replies

5. Infrastructure Monitoring

diffrence between method call and function call in perl

Hello, I have a problem with package and name space. require "/Mehran/DSGateEngineLib/general.pl"; use strict; sub System_Status_Main_Service_Status_Intrusion_Prevention { my %idpstatus; my @result; &General_ReadHash("/var/dsg/idp/settings",\%idpstatus); #print... (4 Replies)
Discussion started by: Zaxon
4 Replies

6. UNIX for Dummies Questions & Answers

Why do I need to call make if I call gcc ?

Why do I need to call make if I call gcc ? I thought gcc already compiles the sources. thanks (1 Reply)
Discussion started by: aneuryzma
1 Replies

7. Ubuntu

Kernel boot options removed by fault, no boot options

Hello Everyone, First of all, I highly appreciate all Linux forum members and whole Linux community. http://forums.linuxmint.com/images/smilies/icon_wink.gif. I wish you the best for all of you ! I will try to be short and concise: I am using Linux Mint 10 for 2 months on 2 ws, and all went... (3 Replies)
Discussion started by: cdt
3 Replies
YESTERDAY(1)						      General Commands Manual						      YESTERDAY(1)

NAME
yesterday - print file names from the dump SYNOPSIS
yesterday [ -c ] [ -date ] files ... DESCRIPTION
Yesterday prints the names of the files from the most recent dump. Since dumps are done early in the morning, yesterday's files are really in today's dump. For example, if today is March 17, 1992, yesterday /adm/users prints /n/dump/1992/0317/adm/users In fact, the implementation is to select the most recent dump in the current year, so the dump selected may not be from today. With option -c, yesterday copies the dump file to the current directory. The date option selects other day's dumps, with a format of 2, 4, 6, or 8 digits of the form dd, mmdd, yymmdd, or yyyymmdd. Yesterday does not guarantee that the string it prints represents an existing file. EXAMPLES
Back up to yesterday's MIPS binary of vc: cd /mips/bin yesterday -c vc Temporarily back up to March 1's MIPS C library to see if a program runs correctly when loaded with it: bind `{yesterday -0301 /mips/lib/libc.a} /mips/lib/libc.a rm v.out mk v.out FILES
/n/dump SOURCE
/rc/bin/yesterday SEE ALSO
fs(4) BUGS
It's hard to use this command without singing. YESTERDAY(1)
All times are GMT -4. The time now is 08:41 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy