Sponsored Content
Top Forums UNIX for Dummies Questions & Answers How to run multiple piped commands in a find -exec statement? Post 302543896 by a20786 on Tuesday 2nd of August 2011 10:59:06 AM
Old 08-02-2011
Find with Pipe

Try this

find . -type d -name somedirname -exec ksh -c 'echo -n $1" ";ls -ltr $1|wc -l' {} {} \;


This will serach for all directories from current direcotry and will give count of number (+1) of files/dirs present in that directory.

For your original question:
find . -type f -name "*.dat" -exec ksh -c 'echo -n $1" ";grep XXXX $1|wc -l ' {} {} \;
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Command to run multiple commands from a file.

I need a command, which could run mutliple commands from a file. Let's say, I have mv fileA1 fileB1 mv fileA2 fileB2 ..... mv fileA20 fileB20 I put these commands in a file, then I need a command to run the file as a whole so that I don't need to type 20 times... Anyone tell me how to... (8 Replies)
Discussion started by: kaixinsjtu
8 Replies

2. Shell Programming and Scripting

How to execute piped command using exec or system

Hi All, I want to execute a piped command like 'ls /opt | grep xml' using array as parameters list. How can I do that? (2 Replies)
Discussion started by: bharadiaam
2 Replies

3. UNIX for Dummies Questions & Answers

How to run two commands from a exec call in a c program

Hi, I have to run two commands one after another from a c program. How can i do this with exec system calls. i tried giving them as argument to execv but it is not working.please help thanks (3 Replies)
Discussion started by: suryashikha
3 Replies

4. Shell Programming and Scripting

find command to use multiple -exec options

Hello All, Is there a way to make exec do a couple of operations on a single input from find? For example, find . -type d -exec ls -l "{}" ";" I would like to give the result of each "ls -l" in the above to a wc. Is that possible? I want to ls -l | wc -l inside exec. How do I... (1 Reply)
Discussion started by: prasanna1157
1 Replies

5. UNIX for Advanced & Expert Users

find -exec with 2 commands doesn't work (error incomplete staement)

Hi Gurues, I need to modify an existing script that uses find to search a folder, and then move its contents to a folder. What I need to do is run gzip on each file after it's moved. So, I ran this little test: Put a ls.tar file on my $HOME, mkdir tmp, and then: virtuo@tnpmprd01: find .... (3 Replies)
Discussion started by: llagos
3 Replies

6. SuSE

Allow multiple users to run several root commands

I am using SUSE Linux Enterprise Server 10 SP2 (i586) and I had earlier ammended my sudoers file to allow users to become root user with "sudo su - " command Now I am trying to add multiple users to the sudoers file to run several commands such as restarting the server, restarting the nagios... (9 Replies)
Discussion started by: hedkandi
9 Replies

7. UNIX for Dummies Questions & Answers

Run multiple commands

Hi All, Is it possible to run second/multiple commands at a time in script before the completion/return of first command? Pls reply. (5 Replies)
Discussion started by: cns1710
5 Replies

8. UNIX for Dummies Questions & Answers

Using find -exec with multiple commands :(-

Hi all, Am wanting to do a ls -l of the files and do a cat of it at the same time, ideally, I am hoping that the following work but obvisouly it is not working to what I am wanting it to ... hu hu hu :wall: find . -name "BACKUP_TIMESTAMP.log" -exec "ls -l basename {} ; cat {}" \; ... (1 Reply)
Discussion started by: newbie_01
1 Replies

9. Shell Programming and Scripting

Run multiple commands in ssh

Hi All, I have the below requirement. I want to copy the local file to remote after that i need to run the local script on a remote machine.When i use two ssh commnds i can achieve this. But i want to achieve this using one ssh command. Below command to copy the local file to remote ssh -q... (2 Replies)
Discussion started by: mohanalakshmi
2 Replies

10. Shell Programming and Scripting

Run 2 exec commands

I have to create two instances of jBoss 5.1.0 GA. In order to do that I have to execute the following in start-jboss.sh: find . -exec /opt/novell/idm/jboss/bin/run.sh -Djboss.service.binding.set=ports-01 -c IDMProv -b 0.0.0.0 \; -exec /opt/novell/idm/jboss/bin/run.sh... (4 Replies)
Discussion started by: Joydeep Ghosh
4 Replies
PDO.EXEC(3)								 1							       PDO.EXEC(3)

PDO
::exec - Execute an SQL statement and return the number of affected rows SYNOPSIS
public int PDO::exec (string $statement) DESCRIPTION
PDO.exec(3) executes an SQL statement in a single function call, returning the number of rows affected by the statement. PDO.exec(3) does not return results from a SELECT statement. For a SELECT statement that you only need to issue once during your program, consider issuing PDO.query(3). For a statement that you need to issue multiple times, prepare a PDOStatement object with PDO.prepare(3) and issue the statement with PDOStatement.execute(3). PARAMETERS
o $statement - The SQL statement to prepare and execute. Data inside the query should be properly escaped. RETURN VALUES
PDO.exec(3) returns the number of rows that were modified or deleted by the SQL statement you issued. If no rows were affected, PDO.exec(3) returns 0. Warning This function may return Boolean FALSE, but may also return a non-Boolean value which evaluates to FALSE. Please read the section on Booleans for more information. Use the === operator for testing the return value of this function. The following example incorrectly relies on the return value of PDO.exec(3), wherein a statement that affected 0 rows results in a call to die(3): <?php $db->exec() or die(print_r($db->errorInfo(), true)); ?> EXAMPLES
Example #1 Issuing a DELETE statement Count the number of rows deleted by a DELETE statement with no WHERE clause. <?php $dbh = new PDO('odbc:sample', 'db2inst1', 'ibmdb2'); /* Delete all rows from the FRUIT table */ $count = $dbh->exec("DELETE FROM fruit WHERE colour = 'red'"); /* Return number of rows that were deleted */ print("Deleted $count rows. "); ?> The above example will output: Deleted 1 rows. SEE ALSO
PDO.prepare(3), PDO.query(3), PDOStatement.execute(3). PHP Documentation Group PDO.EXEC(3)
All times are GMT -4. The time now is 11:47 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy