LinuxQuestions.org
Register a domain and help support LQ
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices



Reply
 
Search this Thread
Old 03-19-2006, 03:48 AM   #1
Bluemilk
LQ Newbie
 
Registered: Mar 2006
Posts: 2

Rep: Reputation: 0
using multiple -exec commands in a single find command?


Hi all,

Is it possible to have multiple -exec's in a single command? lets say i want to gzip up some files that i have found using the find command, and then somehow extract the contents of the gzip file i just created into another folder.
 
Old 03-19-2006, 04:31 AM   #2
acid_kewpie
Moderator
 
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,415

Rep: Reputation: 1968Reputation: 1968Reputation: 1968Reputation: 1968Reputation: 1968Reputation: 1968Reputation: 1968Reputation: 1968Reputation: 1968Reputation: 1968Reputation: 1968
have you tried it? just have a go... (the answer is yes btw) not sure if that's really going to help you with what you're describing though.
 
Old 03-19-2006, 09:43 AM   #3
Bluemilk
LQ Newbie
 
Registered: Mar 2006
Posts: 2

Original Poster
Rep: Reputation: 0
Post

Quote:
Originally Posted by acid_kewpie
have you tried it? just have a go... (the answer is yes btw) not sure if that's really going to help you with what you're describing though.
yea i have tried it. can't get it to work though for some reason...
 
Old 03-19-2006, 09:55 AM   #4
acid_kewpie
Moderator
 
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,415

Rep: Reputation: 1968Reputation: 1968Reputation: 1968Reputation: 1968Reputation: 1968Reputation: 1968Reputation: 1968Reputation: 1968Reputation: 1968Reputation: 1968Reputation: 1968
well you can use multiple exec's easily, but they will work in total isolation on a per command basis, e.g. you might echo the name of the matched file to a log, and then also add it to an archive, but there's no sense of aggregation over the files or anything. you say you want to extract the entire contents of a single archive, well that's not going to be done by processing it on a per file basis unless you explicitly extract each file. sure there are many ways odd things make sense when you know the whole story, but that's never going to make sense!
 
Old 03-19-2006, 11:46 AM   #5
David the H.
Bash Guru
 
Registered: Jun 2004
Location: Osaka, Japan
Distribution: Debian sid + kde 3.5 & 4.4
Posts: 6,823

Rep: Reputation: 1950Reputation: 1950Reputation: 1950Reputation: 1950Reputation: 1950Reputation: 1950Reputation: 1950Reputation: 1950Reputation: 1950Reputation: 1950Reputation: 1950
There are several functions you can use to string together multiple commands in one command line action. The most common one is the pipe "|", which feeds the output from one command into the input of the next. I'd use that instead of multiple -exec functions. Use find to generate a list of files you want to zip up and then pipe it into gzip. Then follow up with a semicolon separator to run a second command to extract them elsewhere.

Open up "man bash" and read the section on shell grammar. Also check out some of the many online shell scripting tutorials, such as LinuxCommand.org, where you can learn a lot about using the shell in general as well. With a little work you can become comfortable with the command line in no time. ^o^

Last edited by David the H.; 03-19-2006 at 11:52 AM.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
how can I execute two commands on exec of a find? eantoranz Programming 3 08-03-2010 05:51 PM
How to execute multiple commands with find and -exec... tomstratton Linux - General 6 05-26-2009 04:26 AM
Compiling multiple .c file using single command in makefile vipulc Linux - General 2 03-19-2006 12:49 AM
redhat 9.0 how to use the command 'find' with the action -exec arvin_shu Linux - Newbie 3 11-30-2005 08:09 AM
Multiple commands with exec! dtheorem Linux - General 1 03-14-2004 04:46 PM


All times are GMT -5. The time now is 04:27 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration