Unable to execute the complete cmd - using find command


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Unable to execute the complete cmd - using find command
# 8  
Old 12-21-2011
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.
# 9  
Old 12-21-2011
Put the below patterns in one file ( pattern.txt )

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

And now, execute the below command.


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

# 10  
Old 12-21-2011
Thanks. Let me try.

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

Getting the error:

while: Expression syntax
# 11  
Old 12-21-2011
Quote:
Originally Posted by venkatesht
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
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)
Code:
# 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)
Code:
(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)
Code:
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
# 12  
Old 12-22-2011
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.

Code:
 
find . "*ibts*" -print

and

Code:
 
find . "*Ibts*" -print


Regards,
Venkat.
# 13  
Old 12-22-2011
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 Smilie
Sunfreeware - Free and Open Source Software (FOSS) for Sun Microsystem's Solaris
regards
ygemici
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Advanced & Expert Users

Find command takes too long to complete

Hi, Below is my find command find /opt/app/websphere -name myfolder -perm -600 | wc -l At time it even takes 20 mins to complete. my OS is : SunOS mypc 5.10 Generic_150400-09 sun4v sparc SUNW,T5440 (10 Replies)
Discussion started by: mohtashims
10 Replies

2. Shell Programming and Scripting

Execute command using ssh server 'cmd'

Hi The command below does not work as it require to take command in the breakers But If I do so the variable values get lost ssh testserver01 'dsmc q b "${ARCHIVE_DIR}*" -sub=yes -querysummary -inactive -fromd="${BACKUP_DATE}"' Thank you. (3 Replies)
Discussion started by: zam
3 Replies

3. Shell Programming and Scripting

Telnet using port and execute cmd

Hi, my query is: I am Login on server with IP xxx.xxx.xxx.xxx.. and i want a script where i want to telnet to server with IP yyy.yyy.yyy.yyy using specific port and then execute a cmd there on server Y please suggest (1 Reply)
Discussion started by: dodasajan
1 Replies

4. Linux

How to execute nohup cmd

Hi, nohup sar -u 10 $COUNT | awk 'NR>2 {$2=$4=$7="";}1' | tr -s ' ' '\t' 2>/dev/null >sar.out & i have execute above line from shell script .. but sar.out is created with ZERO bite size.. Help on that what is the problem here Thx, Mani (0 Replies)
Discussion started by: Mani_apr08
0 Replies

5. AIX

Unable to find crypt command

Hi Friends, I am not able to execute crypt in AIX OS. Could you pls let me know how to get this command. Thanks in Advance Siva. (1 Reply)
Discussion started by: sivakumarl
1 Replies

6. AIX

Unable to execute snap command

Hi Friends, I am not able to execute snap -a command in AIX 6 system. Could you please let me know how to make work this command and Path to be set. Thanks in Advance Siva. (4 Replies)
Discussion started by: sivakumarl
4 Replies

7. Shell Programming and Scripting

Unable to find java command

Hi All, Am trying to start a server by using the startup shell script. But am getting java command not found. Can anyone guide me in which path i need to check for all the java commands and also how do i chk the version of java being installed on linux box? Thanks (3 Replies)
Discussion started by: Ashok_oct22
3 Replies

8. Forum Support Area for Unregistered Users & Account Problems

Help! I'm unable to complete my registration

I have followed the instructions contained in my confirmation email and when I do I am referred here: https://www.unix.com/register.php?a=act&u=302021451&i=94824252. When I follow the instructions on that screen I am directed to the same error page. Please assist. Thank you in advance. (1 Reply)
Discussion started by: ramiller01
1 Replies

9. Shell Programming and Scripting

Need to execute a complete url from crontab

Hi, I need to execute a URL through crontab. Please could you help me to. I need something like 15 0 * * * http://www.mysite.com/index.php. Is it possible. If not, how can I execute a script from another server.. Any help will be appritiatable. Many thanks, Nissar.P.K (2 Replies)
Discussion started by: nissar
2 Replies

10. UNIX for Dummies Questions & Answers

UNable to find ping command

HI, I am new to unix. I have used some basic commands and written some simple shell scripts in teh past. Currently, I am supposed to write a script to continuosly check if a couple of machines are up and if not to start a script. I am using a bash - 2.03. I have tryying to use the ping command... (3 Replies)
Discussion started by: swepaul
3 Replies
Login or Register to Ask a Question