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:
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.
methyl
March 20, 2012, 9:05am
3
Please post what Operating System and version you have and what Shell you prefer.
As posted this does not execute the expr
.
Did you mean:
c=`expr $n \* $m` #value comes to -10 when echoed
Or perhaps if you have a modern Shell:
c=$((n * m))
Thanks Frank and Methyl.
I tried the suggested options but they didnt work.
I use bash shell and the below version of linux
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
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
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.
there should not any space after the = (equal symbol)
d=$(expr $m \* $n )
Thanks Itkamaraj.
That worked.
I am new to shell scripting.Will be careful of such nuances.