|
Home > Archive > Unix Shell > March 2005 > passing a number as parameter1 to the script
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
passing a number as parameter1 to the script
|
|
| prabhat143@gmail.com 2005-03-11, 5:59 pm |
| 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?
Thanks,
Prabhat
| |
| prabhat143@gmail.com 2005-03-11, 5:59 pm |
| Thanks and adding shift works. I am using -atime as I want to delete
files that were created certain days before.
What does shift do?
Regards,
Prabhat
| |
| Chris F.A. Johnson 2005-03-11, 5:59 pm |
| [please quote relevant portions of the message you are replying to]
On Fri, 11 Mar 2005 at 17:11 GMT, prabhat143@gmail.com wrote:
> Thanks and adding shift works. I am using -atime as I want to delete
> files that were created certain days before.
Unix file systems do not retain the creation date; they have last
modification time, time of last change of status, and time of last
access. In find, these are -mtime, -ctime, and -atime.
> What does shift do?
"shift N" remove the first N positional parameters; if not
specified, N defaults to 1.
--
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
| |
| Daniel Vallstrom 2005-03-11, 5:59 pm |
| prabhat...@gmail.com wrote:
> Thanks and adding shift works. I am using -atime as I want to delete
> files that were created certain days before.
>
> What does shift do?
Please quote what you are replying to. $@ denotes the list of arguments
and 'shift' shifts the list one step so that $1 is removed, the old $2
becomes the new $1, and so on.
Daniel Vallstrom
|
|
|
|
|