Sponsored Content
Full Discussion: FIND and GREP syntax
Top Forums UNIX for Beginners Questions & Answers FIND and GREP syntax Post 303043013 by Neo on Wednesday 15th of January 2020 11:32:21 PM
Old 01-16-2020
Reference:

https://www.unix.com/man-page/centos/1/find/

Code:
 
       -exec command ;
	      Execute command; true if 0 status is returned.  All following arguments to find are taken to be arguments to the	command  until	an
	      argument	consisting  of	`;'  is  encountered.	The string `{}' is replaced by the current file name being processed everywhere it
	      occurs in the arguments to the command, not just in arguments where it is alone, as in some versions of find.  Both  of  these  con-
	      structions  might  need  to be escaped (with a `') or quoted to protect them from expansion by the shell.  See the EXAMPLES section
	      for examples of the use of the -exec option.  The specified command is run once for each matched file.  The command is  executed	in
	      the  starting  directory.   There are unavoidable security problems surrounding use of the -exec action; you should use the -execdir
	      option instead.

       -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.
	      The command line is built in much the same way that xargs builds its command lines.  Only one instance of `{}' is allowed within the
	      command.	The command is executed in the starting directory.

Very simple example using ;

Code:
find / -exec grep hello {} \;

the \; symbols terminate the -exec statement.

FWIW, I tend to always terminate with the semicolon in day-to-day practice.
This User Gave Thanks to Neo For This Post:
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Need help with the syntax using awk+grep

Hi, I need to extract information from a 4 GB file based on the following conditions: 1) Check for the presence of a set of account numbers Each account number is present along with other information within a PAGESTART and PAGEEND. The file looks like this: PAGESTART ACCOUNT NO 123... (6 Replies)
Discussion started by: kthri
6 Replies

2. Shell Programming and Scripting

grep syntax for this...

I wanna grep for a pattern logs 1 2 & 3 within a folder containing 100 logs grep "test" /folder/log1 /folder/log2 /folder/log3 The above command will work fine but is there any command like grep "test" /folder/log1, log2, log3 or something similar (4 Replies)
Discussion started by: roshanjain2
4 Replies

3. Shell Programming and Scripting

Can I know find syntax to find given date files

Hi All, Can i use find command to know given date files? If yes, then please let me know the syntax for the same. Thanks in advance for your postive responses Regards, Bachegowda (3 Replies)
Discussion started by: bache_gowda
3 Replies

4. BSD

proper syntax of grep command

I'm learning UNIX on my mac (BSD), using a manual. I'm trying to figure out the grep command, and am getting something wrong. I've opened one of my files in NeoOffice and am looking for a string, the phrase 'I am writing.' I've been to some sites to get the proper syntax, and from what I can see... (5 Replies)
Discussion started by: Straitsfan
5 Replies

5. UNIX for Dummies Questions & Answers

| help | unix | grep (GNU grep) 2.5.1 | advanced regex syntax

Hello, I'm working on unix with grep (GNU grep) 2.5.1. I'm going through some of the newer regex syntax using Regular Expression Reference - Advanced Syntax a guide. ls -aLl /bin | grep "\(x\)" Which works, just highlights 'x' where ever, when ever. I'm trying to to get (?:) to work but... (4 Replies)
Discussion started by: MykC
4 Replies

6. Shell Programming and Scripting

Perl Grep Error - Possible Syntax?

Alrighty, I'm trying to get a perl script going to search through a bunch of files for me and compile it to a single location. I am currently having troubles on just getting the grep to work. Here is what I currently have: #!/usr/bin/perl open (LOG, "errors.txt") or die ("Unable to open... (2 Replies)
Discussion started by: adelsin
2 Replies

7. Shell Programming and Scripting

find syntax

i'm trying to find out how to find in my directory and subdirectories a certain file. once i find that file, i need to select that folder and copy it the location or output it to a new text file. i know how to find the file by using find . -name \*.pl | sort -n but idk how to select... (9 Replies)
Discussion started by: kpddong
9 Replies

8. UNIX for Dummies Questions & Answers

Find/Grep Syntax Question

Hi Folks, I am trying to dig through about 100 directories that have 1 or 2 .jpg images stored in each. I want to copy the .jpg to another file in the root directory. Really my ultimate goal is not to have to dig down into each directory to copy the images individually. I thought I could use a... (2 Replies)
Discussion started by: alpinescott
2 Replies

9. Shell Programming and Scripting

Grep syntax print after certain character

My current code is: user@ubuntu:~/Desktop$ grep -e "\(packaged by\)\|\(employee\)\|\(file name\)\|\(Total Data (MB) Read\)\|\(Begin Time\)" log.txt packaged by = Ron Mexico employee = Michael Vick file name = Mike_Vick_2011.bat Total Data (MB) Read: 11.82 Begin Time: 6/13/2011... (8 Replies)
Discussion started by: chipperuga
8 Replies

10. Shell Programming and Scripting

Help on grep syntax in UNIX

Dear Team /app/Appln/logs/ echo Session used server are 'grep -i pid|grep -i session | cut -d'.' -f1 | awk '{print $9}' | sort | uniq' Output - lxserver01 lxserver02 lxserver03 When I grep session pid in logs server details I can see above distinct server details but I... (6 Replies)
Discussion started by: skp
6 Replies
findfiles(1)						       PythonCard Developers						      findfiles(1)

NAME
findfiles - Utility to locate files containing specific content SYNOPSIS
findfiles [switches] DESCRIPTION
Very often when you are programming in any programming or scripting language, you want to find out how a particular function works or whether a particular property is settable, or any of a number of other questions. In many cases, you can find the answers to your questions by looking at the source code of the application or tool you're using. This is sometimes referred to as "code shopping," particularly when what you really hope to find is a method that does exactly what you want to do. The PythonCard findfiles tool is designed to support you in these efforts. Type in a string for which to search, tell findfiles the directories (yes, you can have more than one) in which to search for files con- taining that string, and send findfiles off to locate files with that specific content. Scroll through the list of files, each with a line reproducing part of the located line for each occurrence in the file, find the one you think is what you are looking for, and double-click the line. Voila! The PythonCard codeEditor tool opens and scrolls instantly to the line you've selected. SWITCHES
-p Show property editor -m Show message watcher -l Enable logging -s Show shell -m Show namespace -d Show debug menu REGULAR EXPRESSIONS
The findfiles utility uses classic Unix grep (regular expression) searches. The grep utility uses a technique called regular expression matching to locate information. In regular expressions, some characters have a special meaning. If you want to search for any of these special characters in the strings you supply in findfiles, you'll have to escape them by preceding them with a backward slash () character. While there are many such characters in regular expressions, the ones with which you will need to be most careful are: question mark (?), asterisk (*), addition/concatenation operator (+), pipe or vertical bar (|), caret (^) and dollar sign ($). To search for a dollar sign in the target directories, for example, put "$" into the search field. (Putting in a $ by itself will crash findfiles fairly reliably.) On a Debian system, you can see the manpages for grep(1) or regex(7) for more information on grep and regular expressions. NOTES
The findfiles utility also provides additional functionality that is not discussed in this manpage, because it is somewhat difficult to completely describe usage of a GUI program in a text-based manpage. For more detailed usage instructions or for more information on the PythonCard GUI framework in general, you should install the pythoncard-doc package and take a look at the various walk-throughs, tutorials and samples included with it. Once the pythoncard-doc package is installed, the documentation is installed to /usr/share/doc/pythoncard-doc, and is also available via Debian's doc-base infrastructure - find it in the Devel section using dwww(1), doc-central(1) or dhelp(1). If you would rather not install the pythoncard-doc package, you can find essentially the same information on the PythonCard website: http://pythoncard.sourceforge.net BUGS
Although it is considered to be stable, this is still development-level software. Please report bugs in this or any PythonCard component to the Debian Bug Tracking system using reportbug(1). AUTHOR
This manpage was written by Kenneth J. Pronovici <pronovic@debian.org>, for use by the Debian project. Content was based on previously- existing PythonCard documentation in other forms. SEE ALSO
codeEditor(1), resourceEditor(1), PythonCard GUI Framework August 2003 findfiles(1)
All times are GMT -4. The time now is 10:51 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy