PDA

View Full Version : strange problem : grep ^- in cron is not working


Manikandan
03-25-03, 14:29
Hi,
I have crontab which initiates the shell called call.sh.
My call.sh is :

var=`ls -ltr |grep ^-|tr -s " "|cut -d " " -f9|grep ^INP|sort`
echo $var

here when i run a crontab am getting the error
call.sh . INP not found.

I think the usage of grep ^ is having some problem while using in crontab.

can ne 1 pls help me..
Thanks in advance
~V~

sathyaram_s
03-27-03, 06:15
A sort at the end of the command defeats the purpose of the 'tr' options in 'ls -ltr' ...

I do not know why yurs does not work in cron , but you can do the same using te below script:

ls -p | sed '/\//d'

sort is not required as ls produces an alphabetically sorted list.

Hope this helps

Cheers

Sathyaram



Originally posted by Manikandan
Hi,
I have crontab which initiates the shell called call.sh.
My call.sh is :

var=`ls -ltr |grep ^-|tr -s " "|cut -d " " -f9|grep ^INP|sort`
echo $var

here when i run a crontab am getting the error
call.sh . INP not found.

I think the usage of grep ^ is having some problem while using in crontab.

can ne 1 pls help me..
Thanks in advance
~V~