General :: Recursive Search For Files That Hold Some Specific Text?
Jan 18, 2011
How do I recursively generate a text file which has a list of all files on my server which contain a specific string anywhere in the files?
I know the following command can be used to replace a string recursively
find /var/www -type f -print0 | xargs -0 sed -i 's/old string/new string/g'
I do not want to replace the string, I just want a list of all files which contain the string.
View 4 Replies
ADVERTISEMENT
Oct 28, 2009
find out a command to search among all *.dat files in a certain path (including subdirectories) looking for the following text in them:
Code:
--------------------------------------------------------------------------------
Elements with small area
Element Adjusted nodes
--------- --------------
16294 NO
17889 NO
and getting the list of elements with small area printed in a file "ErrorEl.txt". The output should have this form:
"/path/01/A.dat
bad-el#01
bad-el#02
[code]....
I know already how to find out the dat files containg a certain string
Code:
c=/path/
grep -R --include="*.dat" "Elements with small area" $c | cut -d: -f1>> ErrorEl.txt
but I don't know then how to get the element numbers(16294 and 17889 in the example above)
View 11 Replies
View Related
Mar 4, 2011
I would like to be able to recursively delete specific various files from a directory and sub-directories. For example:
Dir/
|_sub1/
|
|_ _rm *file1 *file2 *file3
[code]....
View 11 Replies
View Related
Apr 21, 2010
Currently, when I'm searching text in files of my PHP project, I use this line :
Code:
grep -r 'myTextToFind' *
But now, I would like to search only in ".lang" files. How can I do that ?
View 7 Replies
View Related
Dec 2, 2010
How can I search files modified in a specific day?
View 2 Replies
View Related
Jul 24, 2010
I need to search a bunch of files in a specific folder for a specific number and add all the numbers together to a total sum. I use Rsync everyday, everytime I run rsync i get a logfile (rsync output) witch contains the textstring "Total bytes sent: xxxxxx".
The "xxxxx" can vary in lenght. I need to extract the "xxxxxx" from each file and add the numbers together to a total size over a week or a month. Is this possible? And I wish to only use bash. One way of doing stuff at a time my friends .
View 5 Replies
View Related
Mar 17, 2010
i want such a shell script or single line command to delete all the files with extension specified in script i have bash !! ex... delete all files of extension .obj
View 4 Replies
View Related
Feb 3, 2011
Long story short, I got a folder with nearly 800,000 php files. I would like to search each file for a string and if it exists in that file, the file gets copied to another directory. Is this possible from the terminal? So far I got: grep -i -n -r 'ppr-1792' * | cp $1 move_to_here
But this obviously doesn't work. $1 needs to be the file name that contains matching text.
View 2 Replies
View Related
Sep 3, 2010
how to search in files text that is one-byte encoding? places - search for files in gnome in ubuntu searches only utf-8 text.i know one way: install wine and total commander, then search with it. what are better ways?[URL]
View 4 Replies
View Related
Mar 30, 2011
I am using find some_dir -name "*.some_ext" | xargs -l10 grep "some_expr"
to find files in folder, but I just want to display the file name but not all file content. Any solution?
View 2 Replies
View Related
Nov 20, 2010
I am a member of a group which has written a program whose source code is being held in a specific directory (~cs252/Assignments/basicAsst/project) and we want to go through and change the parameters for the function "sequentialInsert." My job is to find all occurances of the function call to "sequentialInsert" and to also list the files from where the code came from. Also, I have to be in the commandsAsst directory when I do this. I have tried grep and find combined together, and I am at a lost.
View 1 Replies
View Related
Oct 27, 2009
Is there an app or find parameter that can search for video files using a specific (DivX for example) encoding? On Windows, you can do this, so I was hoping there would be some way on Linux whether it's with find or another app. I want to find all (*.avi OR *.divx) on my file system with the DiVX fourcc tag (i think that's what its called)
View 4 Replies
View Related
May 5, 2010
I need to create a report ,
The data is spread across two files in below format,
File 1
=========
<Class Name1>
Ph: 001
Place: place001
</class>
[Code]....
View 4 Replies
View Related
Dec 2, 2010
for example
else {
for fileDOC in $location/*.doc
do
[code]...
View 12 Replies
View Related
Jul 14, 2011
I am looking for a one liner to search for a string in file(s) which are in a tar ball (.tar.bz2 in my case)
Code:
-bash-3.2$ tar -tjf /var/log/ABC/07142011-1412.tar.bz2
var/log/ABC/07142011-1412/
var/log/ABC/07142011-1412/live_hosts.txt
var/log/ABC/07142011-1412/all_hosts.txt
var/log/ABC/07142011-1412/LOGS.txt
How can I recursively look inside all the txt files in this tar file ?
View 10 Replies
View Related
Mar 6, 2010
I have a hidden folder with a lot of text files in it. I would like to search in this folder for all files containing a given text.The File Browser's" FIND searches only in the file names, not in their contents.The FIND function of Ubuntu does not allow me to search ONLY in the given hidden folder. So, how can I find my files within the hidden folder with the given text within them?
View 7 Replies
View Related
Feb 28, 2011
I know grep can search recursively (ie through all subdirectories to the bottom of the directory tree), but is it possible to ask grep to only search say, 3 levels down? That means the current directory, any directories in the current directory, and within any directories within those?
View 1 Replies
View Related
Aug 3, 2010
I'm wanting to mod some PHP files across a hierarchy and thought I'd drive it with find + grep + xargs
I built up a command line which I was confident would do the job, but now can't save the results.
First I tried this:
Code:
find . -name *.php | xargs grep serialize | cut -d: -f1| sort -u | xargs sed -i s/serialize/serialise/g
but that didn't work:
Code:
sed: illegal option -- i
so I thought I'd try using
Code:
[Code].....
View 10 Replies
View Related
Apr 16, 2010
I am writing a shell script that finds all files named <myFile> in a directory <dir> or any of its subdirectories, recursively. I also need to take care of symbolic links that may form cycles, to avoid infinite loops. I am not supposed to use find command for the same
I started writing the code but got stuck. I thought using recursion may be a smart way, but its not working.
Code:
#!/bin/sh
findFiles()
{
thisDIR=$1
#cd $thisDIR
code....
View 5 Replies
View Related
Aug 17, 2010
I lost an important file. I know what bytes the file begins with. How can I search the partition for the sequence of bytes?
View 4 Replies
View Related
Mar 10, 2010
If i am in the root directory and i need to search for a specific file in the sysconfig directory, is there any way to search this directory for a file?
View 10 Replies
View Related
Mar 6, 2010
To search a string pattern in all files in a directory and subdirectories, I am using;
Code:
grep -R "myclass::my-func(" mydirectory/
Now I want grep, to search in only specific file types say *.cc. Please help me. I have read manual of grep, but could not deduce any hint.
Best Regards.
View 7 Replies
View Related
Jun 29, 2010
is there a recursive shell or Perl script to delete files with the same name as the parent folder? i wish to include the starting folder name as argument to the script.
View 2 Replies
View Related
May 19, 2011
What would be the best way to search for a file that contains a string similar to this:
View 1 Replies
View Related
Nov 28, 2010
I need to search for a string "teststring" in all *.java files coming under /home/user1/ (including subfolders). How can I do it in linux via shell command.
View 5 Replies
View Related
Jul 12, 2011
I have a html page and I would like to search for the occurance of a given string as an anchor. Then I would like to search backward for a the first match to a given regular expression. As a result I would like to output the text between the two points.
Please note that I would like to have the output up to the first regex match before the ANCHOR point.What is the best tool to solve this?
View 1 Replies
View Related
Sep 17, 2010
I have done a bunch of searches on this but the terms seem to get tangled in the more popular search of "colouring the output of grep / awk". I am trying to find a way to grep/awk through the output of a command to find text of a specific colour. The command's output has a range of colours signifying too many different things to specify using text, with colour being the only form of grouping.
View 5 Replies
View Related
Aug 2, 2011
I have a file called Regions.ini that looks like this:
Code:
[Granite]
RegionUUID = 54ab7cd2-0e70-49b7-8020-8dbeb84c08d0
Location = 9991,10007
InternalAddress = 0.0.0.0
InternalPort = 9001
AllowAlternatePorts = False
ExternalHostName = 71.171.21.9
[Syenite]
RegionUUID = 8fc56fdd-0afd-4074-9432-0ae8f42b799f
Location = 9992,10007
InternalAddress = 0.0.0.0
InternalPort = 9000
AllowAlternatePorts = False
ExternalHostName = 71.171.21.9
What I need to do is find out what the IP address is after "ExternalHostName ="
After that I will need to compare that IP to whatismyip and if it's different then replace it but that is easy to do with sed. I just can't figure this simple hurdle out.
View 12 Replies
View Related
Nov 23, 2010
I've got a big text file in which I know have probably made some typos (LaTeX). Sometimes I rewrite sentences several times and then end up with double pieces like "the the" or "is is" without noticing it. Most spell checkers that I can use in LaTeX are very basic so they do not notice these grammar errors. Is there a way that I can search for these repetitions by hand using sed or awk or something along these lines? Is there an app for that?
View 3 Replies
View Related
Feb 3, 2011
Suppose I have a pair of files containing lists. The first file is called contigs.txt and it contains a list that looks like this:
Code:
Contig822
Contig826
[code]...
View 5 Replies
View Related