Unable to execute the complete cmd - using find command

Hi,

I'm unable to execute the below command completely ; it's not allowing me to type the complete command. It is allowing till "xargs" and i cannot even press enter after that.

I'm using Solaris. Let me know if anything needs to be added so as to execute the complete command. Appreciate your help in this regard.

Many thanks in advance.

Regards,
Venkat

Put it in a file and execute it .. :slight_smile:

Thanks.

I tried in the same way by putting it in a file and executing (./<<file name>> ), getting the "ls -ltr" output but not the desired one.

#!/bin/csh

No the desired one ..then what is the expected output you need ..

if the results of find is NULL, xargs lists everything where s in the current directory(.)

Jayan - I'm expecting the output with all the files that have the matching patterns given in the find command.

Just customized your find command .. Try and let us know ..

find $DIR -type f \( -iname "*bak*" -o -iname "*bkup*" -o -iname "*[0-9][0-9]*" -o -iname "*gcm[sc]*" -o -iname "*itnb*" \) -mtime +10 -exec ls -ltr {} \; 2>/dev/null | grep -v snapshot

Getting the error "Ambiguous output redirect". The command which i reported initially is working fine on linux boxes. Not sure why it's not working on Solaris boxes.

Put the below patterns in one file ( pattern.txt )

 
*[_.]bak*
*[_.]bkup*
*[_.][0-9][0-9]*
*[_.]gcms*
*[_.]itcm*

And now, execute the below command.

 
while read pattern; do find . -iname $pattern -mtime +10 | grep -v "snapshot" | xargs ls -lrt ; done < pattern.txt

Thanks. Let me try.

---------- Post updated at 03:10 AM ---------- Previous update was at 03:01 AM ----------

Getting the error:

while: Expression syntax

actually your first command almostly is like ok but due to the length of the your command , it's not allowed by csh for cmd line length..(256 chrs)
you can maybe try in tcsh if support "iname" by `find` ..(change location grep and xargs for more effect)

# tcsh
# find . \( -iname "*.bak*" -o -iname "*_bak*" -o -iname "*.bkup*" -o -iname "*_bkup*" -o -iname "*.[0-9][0-9]*" -o -iname "*_[0-9][0-9]*" -o 
-iname "*gcms*" -o -iname "*_gcms*" -o -iname "*itcm*" -o -iname "*_itcm*" \) -mtime +10 | xargs ls -ltr | grep -v "snapshot"

and scond (redirctn)
unfortunately csh redirection has some problems and difficulties.therefore maybe you can use like below.(if you redirect stderr)

(tcsh;set DIR="yourpath";find $DIR -type f \( -name "*bak*" -o -name "*bkup*" -o -name "*[0-9][0-9]*" -o -name "*gcm[sc]*" -o 
-name "*itnb*" \) -mtime +10 -exec ls -ltr {} \;  >/tmp/fa.out) >& /dev/null && grep -v snapshot /tmp/fa.out

and another(while)

set nonomatch
set pattern=`cat pattern.txt`
set i=1
while ($i <= $#pattern)
find . -name "$pattern[$i]" -mtime +10 |xargs -l ls -ltr |grep -v snapshot
@ i++
end

regards
ygemici

Thanks a lot ygemici and everyone.

I have one more question. The flag -iname in find command is not working on solaris. Do not find the relative flag to ignore case sensitive in find command. Pls help.

Need to search the patterns of the below format.

 
find . "*ibts*" -print

and

 
find . "*Ibts*" -print

Regards,
Venkat.

i can a write simple find script with ignorecase opt but it's not best method and not effective (definitely runs slower)..
the best way is to install gnu find_utils :b:
Sunfreeware - Free and Open Source Software (FOSS) for Sun Microsystem's Solaris
regards
ygemici