-$arg not working for find mmin


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting -$arg not working for find mmin
# 1  
Old 03-20-2012
-$arg not working for find mmin

Hi,

I want to parameterise the argument for 'mmin' to find out files created/edited 'n' minutes ago.
For this i have written something as simple as the following:
Code:
n=10
m=-1
c=expr $n \* $m    #value comes to -10 when echoed
find -mmin -10      #works
find -mmin $c      #doesnt work                 
This throws error
find: missing argument to `-mmin'

I tried find -mmin "$c" ,"${c}" ,didnt work.

Kindly help.
Thanks in advance. Smilie

Last edited by methyl; 03-20-2012 at 10:09 AM.. Reason: please use code tags
# 2  
Old 03-20-2012
Code:
c=`expr $n \* $m`

or
Code:
c=$(expr $n \* $m)

or
Code:
((c=n*m))

# 3  
Old 03-20-2012
Please post what Operating System and version you have and what Shell you prefer.

Quote:
c=expr $n \* $m #value comes to -10 when echoed
As posted this does not execute the expr .
Did you mean:
Code:
c=`expr $n \* $m` #value comes to -10 when echoed

Or perhaps if you have a modern Shell:
Code:
c=$((n * m))

# 4  
Old 03-21-2012
Thanks Frank and Methyl.

I tried the suggested options but they didnt work.
I use bash shell and the below version of linux
Code:
Linux Test 2.6.18-92.el5 #1 SMP Tue Apr 29 13:16:15 EDT 2008 x86_64 x86_64 x86_64 GNU/Linux

Code:
g= expr $m \* $n                                 # output: -10
d= $(expr $m \* $n )                           # output:  -10: command not found
e= `expr $m \* $n`                              # output:  -10: command not found
f = $ ((a*b))                                        # output:  f : command not found

Code:
find -mmin $g                                     # find: missing argument to `-mmin'
find -mmin $d                                     # find: missing argument to `-mmin'              
find -mmin $e                                      # find: missing argument to `-mmin'
find -mmin $f                                       # find: missing argument to `-mmin'


Kindly suggest.
# 5  
Old 03-21-2012
there should not any space after the = (equal symbol)

Code:
 
d=$(expr $m \* $n )

# 6  
Old 03-22-2012
Thanks Itkamaraj.
That worked. Smilie
I am new to shell scripting.Will be careful of such nuances.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Find command mmin

Hi, Please tell me what the below command wil do, according to my understanding it finds files in the current and sub directories whose modification time is 5 hrs and it dont zip the already zipped files who's size is more than 4K. Am I Correct? find . -type f -mmin +300 ! -name... (1 Reply)
Discussion started by: nag_sathi
1 Replies

2. Shell Programming and Scripting

Getting file Details with find -mmin

I'm new to this and I have done a lot of research and am 99% done with my ksh script BUT I need help with. The script looks at Journal files and reports back on any that have not been updated for 15 min. Everything works but I wanted more detail (added -ls) and now I'm getting dups. Original code:... (2 Replies)
Discussion started by: blackopz
2 Replies

3. Shell Programming and Scripting

Find mmin, mtime, cmin not working

Dear All, We are having the script which is creating the folder on another server if it is not present using ssh. Using scp it copies copy all pdf files from local folder to server folder. After all copy is done, Just to verify i was using the below find command find... (3 Replies)
Discussion started by: yadavricky
3 Replies

4. Shell Programming and Scripting

mmin not working in ksh

We have created a unix shell script to read a datafiles from specific input directory in Unix. Users will be copying datafiles to the same input unix directoty. During Testing we observed Unix Shell Script also read the incomplete datafiles which is still copying by the users. As per requirement... (1 Reply)
Discussion started by: Kumari Reshma
1 Replies

5. Programming

warning: int format,pid_t arg (arg 2)

I try following code under Solaris10,like follows: int glob = 6; int main(void) { int var; pid_t pid; var = 88; printf("before vfork\n"); if ((pid = vfork()) < 0) { err_sys("vfork error"); } else if (pid == 0) { glob++; var++; _exit(0); } ... (1 Reply)
Discussion started by: konvalo
1 Replies

6. Shell Programming and Scripting

Help with find –mmin in a .ksh script

I need to compare the time a file was last modified against current time and conditionally proceed. At the command prompt I can do: find MYFILE -mmin +1140 and it lists the file. But I need to test, and if true do something I’ve tried things like: if ; then if ; then etc. ... (2 Replies)
Discussion started by: tlavoie
2 Replies

7. Shell Programming and Scripting

unix find command without mmin option

I need to check if a file has been modified within the last x hours. My find command does not have the mmin option -- only the mtime option which is in 24 hour perriods (1 Reply)
Discussion started by: Bill Ma
1 Replies

8. Solaris

Any alternative of find . -mmin 20

hi find command is not working with -mmin in Solaris Os. Do we hav any alternative to find the modified file in any specified time span ( suppose in last 1- 2 hours) Thanks (2 Replies)
Discussion started by: Prat007
2 Replies

9. HP-UX

find command using -mmin param

Hi Everyone, I would like to know how to find a file which was created in the period of 20+ hours, in most common unix OS, the parameter -mmin is not supported (i.e, HP-UX, Solaris, LInux, AIX) Could you help on this ?? (3 Replies)
Discussion started by: jmbeltran
3 Replies

10. UNIX for Dummies Questions & Answers

no [find -mmin -1]

I wanna show all files like...one minute old, one hour old, five hours old and so on... in my OS (HP-UX) there's only the command .. find -name "..." -mtime -n but this is only for days, there isn't something like -mmin -n ...just don't know what to do. also the newer than option isn't... (3 Replies)
Discussion started by: svennie
3 Replies
Login or Register to Ask a Question