Here is part of my code-

extrafiles1=$(ls mt.*.*.*.*) 
            if [[ $(ls -l $file 2>/dev/null) = *$today* ]]; 
		then
                           if [[ $file -eq $extrafiles1 ]];then
                                    rm $file
                           fi
            fi

when i am running the script it's showing an error--

mtclean[239]: ./mt.log.8882.-5.1202989443474: bad number.
when i just ran this command on the unix prompt itgave me this--
webmut2@france>extrafiles1=$(ls mt.*.*.*.*)
webmut2@france>$extrafiles1
ksh: mt.log.8882.-5.1202983177934: cannot execute
these files dont have execute permission,but they do have -r-w permissions.i have to delete the files with that extensions,please help me out in tht.

why it is so,is the variable assignment is not right.Give me ur suggestions.

--------------------------------------------------------------------------------

Recommended Answers

All 2 Replies

extrafiles1=$(ls mt.*.*.*.*) 
extrafiles2=$(ls *core*)

my question is--
suppose if there is no files matching with the criteria mentioned above it will display message on the window--
mt.*.*.*.* not found
*core* not found

i do not want to display this message on the window even if it do not find any files matching with the criteria,how can i do that.

extrafiles2=$(ls *core* 2>/dev/null)

something like that?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.