Re: passing a number as parameter1 to the script
From: Chris F.A. Johnson (cfajohnson_at_gmail.com)
Date: 03/11/05
- Next message: William: "Re: Expanding variables in scripts using cat"
- Previous message: Daniel Vallstrom: "How to propagate signal down to child? trap erratic; wait not waiting"
- In reply to: prabhat143_at_gmail.com: "passing a number as parameter1 to the script"
- Next in thread: prabhat143_at_gmail.com: "Re: passing a number as parameter1 to the script"
- Reply: prabhat143_at_gmail.com: "Re: passing a number as parameter1 to the script"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: 11 Mar 2005 16:58:14 GMT
On Fri, 11 Mar 2005 at 16:47 GMT, prabhat143@gmail.com wrote:
> Hi,
>
> I have been using the following command recently.
>
> find "$@" -type f -atime +$10
>
> to get the list of all files that are 10 days old. I am trying to write
> a bash shell script(call it listFiles.sh) where user can specify number
> of days as the first parameter to the script and output will be list of
> all files in the current directory and its subdir which are older than
> the user specified date. To be precise, user will call
>
> bash> listFiles.sh 15 //will list files which 15 or more days older
>
> Here is the script I wrote and it gives me an error that I dont know
> how to fix.
>
> ---start of script
> numDays=$1
> echo "Number of days specified " $numDays \;
> find "$@" -type f -atime +$numDays
> ---end of script
>
> The output when given 15 as parameter is:
> Number of days specified 15 ;
> find: 15: No such file or directory
>
> What do I need to do to pass 15 as parameter to -atime flag?
Remove the first positional parameter; you are passing it to find
in "$@". And you probably want -mtime not -atime.
numDays=$1
echo "Number of days specified " $numDays \;
shift
find "$@" -type f -mtime +$numDays
--
Chris F.A. Johnson http://cfaj.freeshell.org/shell
===================================================================
My code (if any) in this post is copyright 2005, Chris F.A. Johnson
and may be copied under the terms of the GNU General Public License
- Next message: William: "Re: Expanding variables in scripts using cat"
- Previous message: Daniel Vallstrom: "How to propagate signal down to child? trap erratic; wait not waiting"
- In reply to: prabhat143_at_gmail.com: "passing a number as parameter1 to the script"
- Next in thread: prabhat143_at_gmail.com: "Re: passing a number as parameter1 to the script"
- Reply: prabhat143_at_gmail.com: "Re: passing a number as parameter1 to the script"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|