Unix/Linux Go Back    


Shell Programming and Scripting BSD, Linux, and UNIX shell scripting — Post awk, bash, csh, ksh, perl, php, python, sed, sh, shell scripts, and other shell scripting languages questions here.

Calling a find/remove within a script

Shell Programming and Scripting


Closed    
 
Thread Tools Search this Thread Display Modes
    #8  
Old Unix and Linux 05-15-2017   -   Original Discussion by jeffs42885
AbelLuis AbelLuis is offline
Registered User
 
Join Date: Jan 2014
Last Activity: 10 August 2017, 11:24 PM EDT
Posts: 28
Thanks: 9
Thanked 10 Times in 10 Posts
This script work fine in my computer:


Code:
#!/bin/ksh 
#Script Below# 
#Add additional lines to config options. 
. ./prune.config 
eval "$DIR1 $DIR1OPTIONS"

Regards.

---------- Post updated at 05:25 PM ---------- Previous update was at 04:12 PM ----------

This also work fine:


Code:
DIR1="find /directory/holding"
DIR1OPTIONS="-type f ! -name \"*.gz\" ! -name "*PDF*" ! -name \"*TIF*\" -size +1000k -mmin +120 -exec gzip {} ;"
$DIR1 $DIR1OPTIONS

(Without the backslash before the semi colon).

Regards.
Sponsored Links
    #9  
Old Unix and Linux 05-16-2017   -   Original Discussion by jeffs42885
RudiC RudiC is offline Forum Staff  
Moderator
 
Join Date: Jul 2012
Last Activity: 22 November 2017, 1:45 PM EST
Location: Aachen, Germany
Posts: 11,644
Thanks: 321
Thanked 3,619 Times in 3,324 Posts
Quote:
Originally Posted by AbelLuis View Post
.
.
.
The final \; for the exec clause is mandatory. I don't know why you add the plus sign to the filename : {}+ .

Try

Code:
-exec gzip {} \;

.
.
.
.
Not necessarily. man find (on my linux: find (GNU findutils) 4.7.0-git)
Quote:
-exec command {} +
This variant of the -exec action runs the specified command on the selected files, but the command line is built by appending each selected file name at the end; the total number of invocations of the command will be much less than the number of matched files.
But: a space before the + may be compulsory.
Sponsored Links
    #10  
Old Unix and Linux 05-16-2017   -   Original Discussion by jeffs42885
AbelLuis AbelLuis is offline
Registered User
 
Join Date: Jan 2014
Last Activity: 10 August 2017, 11:24 PM EDT
Posts: 28
Thanks: 9
Thanked 10 Times in 10 Posts
Quote:
Originally Posted by RudiC View Post
Not necessarily. man find (on my linux: find (GNU findutils) 4.7.0-git)


But: a space before the + may be compulsory.
Yes, it's true. The problem was the lack of a space between {} and +.

Regards.
Sponsored Links
Closed

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Linux More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Can't remove spaces with sed when calling it from sh -c Tribe Shell Programming and Scripting 3 12-13-2014 04:31 AM
Shell script calling Perl function, sort and find data, write to new files kowit010 Homework & Coursework Questions 6 11-02-2011 10:39 PM
Script to find and remove characters Zerby Shell Programming and Scripting 5 01-30-2008 02:16 AM
i am trying to find out who is calling me gail Security 2 07-09-2005 07:48 PM
How to Find who is calling me? uxbala Programming 9 02-15-2005 01:58 AM



All times are GMT -4. The time now is 03:40 AM.