Software :: Grep Recursive Search Directory Depth Option ?

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


ADVERTISEMENT

Fedora :: Configure Grep To Search Recursively Through All Files In A Directory?

Oct 1, 2010

somewhere lurking is a file containing the default print resolution, which is not being overwritten by printer settings or cups management. I've asked on the cup forum and nothing successful.

So here's the question:

How can I configure grep to search recursively through all files in a directory, or if need be starting from root to find the pattern "2880" I've looked in the man page for grep and I can't see how to do it, is grep the right tool to use for this ?

View 2 Replies View Related

OpenSUSE :: Grep And Recursive -r Not Working?

Aug 9, 2010

works fine on a FAT32 dsk:

Code:

fgrep -iRn -C 2 'print' *.txt
---also recurses one level and displays all kinds of data
---------------------------------------------------------------
in root / ext4 directory:

Code:

fgrep -iRn -C 2 'print' *.* or fgrep -iRn -C 2 'print' *.txt
---displays msgs:
fgrep: *.*: No such file or directory
and
fgrep: *.txt: No such file or directory

I am probably missing something very basic.recursive does not seem to work from root directory.Is this (as they used to say) a feature? This is on an 11.2 system, upgraded to 11.3 (ran zypper verify to verify. According to it.. all is well).

View 9 Replies View Related

Programming :: Recursive Search In A Tar.bz2 File?

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

General :: Recursive String-search In Files?

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

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 View Related

Programming :: Multi File Recursive Folder Search And Replace?

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

Programming :: Grep Search Between N-m

Oct 5, 2010

How can i use grep (or any other command) to check for lines that begin with N number.

E.g. I want to print out commands (from history), but only from the command number 50 until #200.

This one doesn't work:

Code:
history | grep "^[50-200]"
Should print out something like:
Code:
50 cd ~/Desktop

[Code].....

View 4 Replies View Related

Ubuntu :: Grep Can't Search Pdf File?

Jun 2, 2010

i want to search some key words in some pdf files grep myword ~/test.pdf that command can't work! grep command can't search pdf file??

View 1 Replies View Related

Ubuntu :: Get A Recursive Listing Of All Files Under The Current Directory?

Jan 2, 2011

If I runls -R1I get a recursive listing of all files under the current directory.However, if I dols -R1 *.avi, ie I want to search only for files with the file descriptor .avi, I get an errorQuote:ls: cannot access *.avi:No such file or directorySo it seems I am using ls incorrectly. What's the correct way to use wild card pattern matching when using the -R switch? Or maybe that isn't possible?

View 2 Replies View Related

General :: Recursive Searching Files In Directory Matching Given Name?

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

Programming :: Compiling Recursive Makefile In Directory Structure

May 18, 2011

I'm having problems with compiling recursive Makefiles in my directory structure:
My folder layout is:
top/|- one/|- one.c (With main function)|- zero.c|- two/|- two.cin my top folder the make file looks like:

Code:
MAKE_DIRECTORIES = one two
.PHONY: all
all: $(MAKE_DIRECTORIES)

.PHONY: $(MAKE_DIRECTORIES)
$(MAKE_DIRECTORIES):
@echo $@
$(MAKE) --directory=$@
in my one and two folder I have the following Makefile:

Code:
.PHONE: all
all:
@echo $@
$(CC) $(CFLAGS) *.c
But when I compile it from top folder: make

I get following output:
Code:
one
two
Which states that directory statement by echo in main Makefile is ok but the files are not compiled in one and two.

View 5 Replies View Related

General :: Use Grep To Search For Multiple Options?

May 20, 2010

How can I use grep to search for line with either 'res' or 'rep'? i try "grep -e res|rep" or gre -e "rep|rep" but that does not work.

View 3 Replies View Related

General :: Search For A String In A Php File Using `grep`?

Jan 19, 2010

I am searching for Class declaration on a site with hundreds of PHP files, how can I do this in the current folder and subfolders using GREP?

I tested cding to the folder and then something like

grep -r 'class MyClass' *.php

View 5 Replies View Related

Ubuntu :: GREP - Return Only Search String?

Jan 13, 2011

I have a mail.log file, of which I want to redirect only the search strings of the sender from=<example.sender@exampledomain.com> and the size size=4537 to a file.

In every case the sender string starts as from=<> and the size string starts as size=

What would be the grep command to redirect only the two search strings to a .txt file?

View 2 Replies View Related

General :: Search A Grep For A Magic Word?

Feb 16, 2011

I am using ascript for general users to back up usb drives to lto4 tapes.. I wish to ahve some error checking to check IF is there is a tape in the tape drive to check for the tape:

if i do a
sudo mt -f /dev/st0 status
i will get back a
mt: /dev/st0: rmtioctl failed: Input/output error
if there is no tape in the drive or
sudo mt -f /dev/st0 status

[code].....

View 4 Replies View Related

General :: Using Grep / Awk To Search For Colored Text

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

General :: GREP - Search Special Characters

Feb 10, 2010

I need to search for the following pattern with GREP in a text file:

So I tried already:

But none of those works...I think probably because GREP doens't like the special character > in the middle of the serach pattern.

At the end I just need to now if GREP found the pattern in the file or not, so it should give me a 0 or a 1 back, once I check the value of the variable "?" after using the grep command.

View 4 Replies View Related

General :: Make A Cronjob Who Makes A Tag.gz Of Everything Inside A Directory In A Recursive Way?

Mar 23, 2011

I would like to make a cronjob who makes a tag.gz of everything inside a directory in a recursive way. BUT there is a HUGE directory full of jpg's. I don't want this one in the backup.Additional points if it can backup symbolic links.

View 2 Replies View Related

Ubuntu :: Is There A Variation Of Grep To Search Files For Keywords

Jul 10, 2010

I know you can use grep to find keywords in filenames, but is there a variation that can enable you to search the content of the files themselves?

View 9 Replies View Related

Ubuntu :: Search Files Containing A String / Grep Command?

Sep 1, 2011

how to search for those files which contain word "AM_COLLECTION=22". I need to know all the files with this string. ( I know the grep command can do it but either

View 4 Replies View Related

General :: Correct Usage Of Grep To Search A Disk?

Mar 26, 2009

I've been trying to identify all files on my cut-down version of Damn Small which contain the text string "User Agent:" in them. Because it's only 120Mb in its entirety, I'm quite happy to have grep search the whole system. I'm using this command, but it just generates errors as you can see:

[root@localhost ~]# grep -R 'User Agent:' /*
grep: /dev/dri/card0: Invalid argument
grep: /dev/fuse: Operation not permitted

[code]....

View 13 Replies View Related

General :: Search Date Period In Access Log Using Grep ?

Feb 19, 2010

I have a three input day,month and year. Currently i am using the following script to take the data.

Any grep advanced technique to avoid for loop?

View 2 Replies View Related

Ubuntu :: Piping Command Output Into Grep As Search Term?

Nov 11, 2010

I want to pipe the output of a command into grep as the search TERM, rather than the text to be searched, like this for example

Code:

cat /var/log/auth.log | grep date "&b &d"

so that I only see the lines in auth.log for the current day...but obviously that line doesn't work.... is there a way to do this with grep, or even another command?

View 4 Replies View Related

General :: Using Grep With -r Option

Feb 19, 2011

I have on my desktop around five java files. I also created a java file in directory Viti, located in desktop.

Since all java files contain string "class", I practice my usage of grep with the following:

And this works fine. However, when I type the following:

I expect to be shown the file that's located in my Viti directory, too, but it won't show it.

View 4 Replies View Related

General :: How To Make Grep To Search A Pattern In Only Specific File Type?

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

General :: Sed/awk/grep Search For Number String Of Variable Length In Text File?

Jan 19, 2010

I need to search a text file for a string of numbers which are different lengths, and always are between number=" and " like:

number="1234567890"
number="22390"

I need to grab those numbers and pipe each one to a line in a file. I've already tried something with awk and that didn't seem to work.

View 10 Replies View Related

General :: Grep Not Recognizing All The Meta-characters When Used With -e Option.

Oct 13, 2010

I was trying to use the grep command with -e option to test some regular expressions with it but to surprise not all the meta characters were being recognized by the grep engine, how ever egrep works perfectly fine.

For example : The following egrp command works fine:

View 3 Replies View Related

Programming :: Copy Files After Search In Array From This Directory To Another Directory?

Jan 3, 2009

After i try to find logfiles follow date/month/year. i want copy this files to another directory with name's directory is time you find(date/month/year).

View 4 Replies View Related

General :: Stop Search Param In Directories By Grep Immediately After Param Match

Jun 17, 2010

I use the following command to find under /var some param in my script

grep -R "param" /var/* 2>/dev/null |grep -wq "param"

my problem is that: after grep find the param in file grep continue to search until all searches under /var/* will completed

How to perform stop immediately after grep match the param word

For example when I run the: grep -R "param" /var/* 2>/dev/null |grep -wq "param"

grep find the param after one second.

But grep continue to Search other same param on other files and its take almost 30 seconds

How to stop the grep immediately after param match?

View 1 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved