Problem with find command


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Problem with find command
# 8  
Old 05-16-2002
Hi kemisola,

I would rather use xargs than exec.

xargs rm

By using xargs in this command, I can remove all of the files that end in .NEW, but instead of creating a separate process for each file , only one process is started through xargs.

That way it is more efficient.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX and Linux Applications

problem with find command

Hi All, I want to search only files more than 60 min in particular directory but not in sub directories. with this command i am getting even sub directires also.Please and let me know how to get the files. $i=`find /home/n1013141/vijay -type f -mmin -60`; print $i; ... (6 Replies)
Discussion started by: bhas1285
6 Replies

2. Shell Programming and Scripting

problem in find command

I am facing problem in find command. I want to read all file names of a directory and write those names in a text file. My script is find /home/Pratik/src -type f -exec basename {} \; >> names.txt The script is working fine and writing all the file names but problem is file names are not... (5 Replies)
Discussion started by: pratikjain998
5 Replies

3. UNIX for Dummies Questions & Answers

Problem with Find command

Hi, I have a script below,which reads dates from No_weekandMonthend_dates.txt performs the copy operation. for i in `cat /tmp/No_weekandMonthend_dates.txt` do cd $Gerenimopath/ZH_LP find . -type f -name "$i_*.txt" -exec cp {} /home/gaddamja/TempLocal \; cd... (2 Replies)
Discussion started by: jagadish_gaddam
2 Replies

4. Shell Programming and Scripting

Problem with find command

Hello Friends, When i give the command from path from path /var/tmp/asirohi/jdk/docs:- find /var/tmp/asirohi/jdk/docs/ . -depth -name license_*.html I get the following output:- /var/tmp/asirohi/jdk/docs/zh_Hant/jre/license_zh_Hant.html... (3 Replies)
Discussion started by: asirohi
3 Replies

5. UNIX for Dummies Questions & Answers

problem with output of find command being input to basename command...

Hi, I am triying to make sure that there exists only one file with the pattern abc* in path /path/. This directory is having many huge files. If there is only one file then I have to take its complete name only to use furter in my script. I am planning to do like this: if ; then... (2 Replies)
Discussion started by: new_learner
2 Replies

6. Shell Programming and Scripting

Problem with find command.

I'm trying to display the full file name (including the full path) and file size of all files whose name (excluding the path) is longer than 10 characters. I came up with find path -type f -name ".{10, }" -printf "%s %p\n", but I'm getting a "find: path: No such file or directory". What's wrong... (2 Replies)
Discussion started by: raidkridley
2 Replies

7. Shell Programming and Scripting

Find command problem

Hi All, I am using following find command to delete the records older than 7 days but getting missing conjuction error.Kindly suggest: The command is: find <complete_dir_path> \(! -name usr -prune \) -type f -name "*.txt" -mtime +6 -print | xargs rm (11 Replies)
Discussion started by: visingha
11 Replies

8. Shell Programming and Scripting

sh : Problem with the result of a find command

Hi I'm working on solaris and I'm trying to run a script. The part listed here does not work properly, the result of the find command is not in the output file /tmp/result (I've checked the find command , executing the shell with sh -x , it seems correct). It seems like I've lost the standard... (4 Replies)
Discussion started by: frenchwill
4 Replies

9. UNIX for Dummies Questions & Answers

Problem with find command when used with mtime

All, Please find the below comand . I am trying to list the file that has not been accesed is past 14 days . But when you look at the display the directory "crecv1" which has date as today is displayed .. Why it is happening . I send this code instead of ls -ltr as rm -f -r in production... (4 Replies)
Discussion started by: arunkumar_mca
4 Replies

10. UNIX for Advanced & Expert Users

Problem with find command in C-shell

when i use the following command find / -name '*.*' -exec grep -il 'text' {} \; I can redirect the errors to /dev/null. This happens only in ksh but not in csh. the 2>/dev/null is not working in csh. Can you some one suggest an alternative for this in csh ? (3 Replies)
Discussion started by: dhanamurthy
3 Replies
Login or Register to Ask a Question
SHELL-QUOTE(1)						User Contributed Perl Documentation					    SHELL-QUOTE(1)

NAME
shell-quote - quote arguments for safe use, unmodified in a shell command SYNOPSIS
shell-quote [switch]... arg... DESCRIPTION
shell-quote lets you pass arbitrary strings through the shell so that they won't be changed by the shell. This lets you process commands or files with embedded white space or shell globbing characters safely. Here are a few examples. EXAMPLES
ssh preserving args When running a remote command with ssh, ssh doesn't preserve the separate arguments it receives. It just joins them with spaces and passes them to "$SHELL -c". This doesn't work as intended: ssh host touch 'hi there' # fails It creates 2 files, hi and there. Instead, do this: cmd=`shell-quote touch 'hi there'` ssh host "$cmd" This gives you just 1 file, hi there. process find output It's not ordinarily possible to process an arbitrary list of files output by find with a shell script. Anything you put in $IFS to split up the output could legitimately be in a file's name. Here's how you can do it using shell-quote: eval set -- `find -type f -print0 | xargs -0 shell-quote --` debug shell scripts shell-quote is better than echo for debugging shell scripts. debug() { [ -z "$debug" ] || shell-quote "debug:" "$@" } With echo you can't tell the difference between "debug 'foo bar'" and "debug foo bar", but with shell-quote you can. save a command for later shell-quote can be used to build up a shell command to run later. Say you want the user to be able to give you switches for a command you're going to run. If you don't want the switches to be re-evaluated by the shell (which is usually a good idea, else there are things the user can't pass through), you can do something like this: user_switches= while [ $# != 0 ] do case x$1 in x--pass-through) [ $# -gt 1 ] || die "need an argument for $1" user_switches="$user_switches "`shell-quote -- "$2"` shift;; # process other switches esac shift done # later eval "shell-quote some-command $user_switches my args" OPTIONS
--debug Turn debugging on. --help Show the usage message and die. --version Show the version number and exit. AVAILABILITY
The code is licensed under the GNU GPL. Check http://www.argon.org/~roderick/ or CPAN for updated versions. AUTHOR
Roderick Schertler <roderick@argon.org> perl v5.16.3 2010-06-11 SHELL-QUOTE(1)