2
votes
4answers
50 views

How to remove text matching specific patterns from a file

I want to compare two files to check for differences between them, fileA and fileB. fileA is like a template file and fileB is the file which I want to compare to it. Anytime I find a difference I ...
2
votes
1answer
31 views

move the search content to different directory

I am on Oracle Solaris. I am using: grep "searchstring" filename.* above command returns my search result. Now I want to move the all the files in above search result (all the files not the ...
1
vote
7answers
807 views

Can grep be used for searching files with some string in their names?

I understand that grep can only be used for searching for files which contain a string in their content. Can it be used for searching for files with a string in their names? I read the manpage, and ...
1
vote
1answer
61 views

grep file from file

What is the fastest way to grep -v a file against another one, both line by line. does grep support this ? Or should I use it on two for loops ?
5
votes
2answers
108 views

Why does a grep reboot the machine?

On a RHEL 6.5 Desktop, if I use: sudo grep -r foo /* my desktop reboots. Q: Why?? How to debug this? It's the third time my Desktop reboots because of this :D
8
votes
4answers
1k views

Grep from the end of a file to the beginning

I have a file with about 30.000.000 lines (Radius Accounting) and I need to find the last match of a given pattern. The command: tac accounting.log | grep $pattern gives what I need, but it's too ...
3
votes
2answers
145 views

How much text does grep/egrep consume each time?

I'm confused on grep/egrep. These tools match a single line I think? In some cases I have heard "logical" line. Questions Is it correct to assume that essentially grep/egrep always processes a ...
3
votes
2answers
407 views

grep string from contents of file command then delete file

I have a peculiar problem I need help with. I have a large batch of .docx files where a certain number of them are junk. I know how to identify these files from the file command, as they contain the ...
5
votes
5answers
339 views

Number of files not containing given string

I read the question about how to find out the number of files that contain a certain string. This is possible with grep -l "string" * | wc -l. Is it possible to invert this, finding the number of ...
2
votes
3answers
1k views

Grep in couple thousands files

I have directory with cca 26 000 files and I need to grep in all these files. Problem is, that I need it as fast as possible, so it's not ideal to make script where grep will take name of one file ...
2
votes
2answers
379 views

Matching two files for similar first line

I have 2 set of files. File one contains ID's ex: 1111 2222 6666 3333 4444 File two contains ID and username: 1873 Neil 1111 Roger 7632 Tim 3333 Oscar 8723 Greg 4444 Roy 6666 Patrick I want to ...
3
votes
5answers
398 views

Print non-existent files from a pipe input

I have a directory of lots of .PDF and .JPG files. There should be a .JPG file for each .PDF with the same name. I'm trying to use a command to find .PDF files that doesn't have a .JPG file. My ...
4
votes
3answers
1k views

shell script to read from multiple files in parallel

I need to write a script that runs parallel and looks for a string in multiple files. I tried a lot of options but they slow down the speed of my processor.
2
votes
2answers
100 views

reformat a text file to have all text on one line using CentOS 5.6

I have a 210-line block of HTML that I have stored in a HTML for debugging purposes. The HTML, as you would expect, is formatted accordingly so is stored in the file with spaces and tabs. Is it ...
0
votes
1answer
1k views

last modified with grep

I'd like to make a list to stdout of the files modified in the last two hours in the . directory using grep. It has to be automatic (can't ask user what time is it or similar stuff) and I have to use ...
1
vote
1answer
166 views

Listing specific lines in listed files

Find all files in /tmp that are ordinary files and print the lines that end with Programming. For this problem I know how to list all files in /tmp. What I do not know how to do is whether to use ...
5
votes
2answers
1k views

How to grep on source code without catching comments

I search a way to grep on source code without having sometimes false-positive because of comments. For instance if I search on foo on this .c source code : /* * foo has changed [...] and is now a ...
3
votes
2answers
739 views

Concatenate specific files into one single file

In a folder containing X files, I need to concatenate Y files (where X > Y) together into a single text file. I have the filenames (of Y files) that I need to concatenate. Can anyone please help me ...
1
vote
0answers
88 views

How to search for file contents [duplicate]

Possible Duplicate: Finding a substring in files across subdirectories with a single built-in command? I know that I can use grep for a single file, but what about a whole directory tree?
7
votes
4answers
5k views

Number of files containing a given string

How can I count the number of files (in a directory) containing a given string as input in bash/sh?