0
votes
1answer
46 views

split a file by a line prefix

My data looks like this: 60 xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx 61 xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx 62 xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx 62 ...
1
vote
1answer
67 views

Windows XP - How do use grep to find strings in files in subdirectories

I once had a version of grep on my PC (I think it came with an early version of Delphi) which supported searching in nested folders with the -r switch. Now something (I suspect a later version of ...
1
vote
3answers
43 views

Is there anything grep does better than ack? [closed]

I started using ack a while ago and it's amazing, but still begs the question: Is there anything grep still does better than ack? Or maybe is there something grep does that ack can't do?
1
vote
1answer
21 views

Pipeing lines to repeat commands

If my grep operation returns a list of ID's like: 12345 84758 49549 .. can I somehow feed/pipe each line to a commandline command's parameter? Like for example with the above result from grep, I'd ...
-2
votes
3answers
67 views

osx bash grep - finding search terms in a large file with one single line

Is there simple unix command line i can enter which lets me isolate say 512 bytes either side of a search term, even if there is only one "line" in a very large text file? Ok, this should be easy. ...
0
votes
2answers
27 views

Use grep to find files and pipe/open to open them

How can I pipe files from grep to open all matching files? I've tried grep -li "type" * | open, but that does not work.
1
vote
2answers
214 views

How can I “grep” recursively filtering the name of the files I want with wildcards?

When I want to perform a recursive grep search in the current directory, I usually do: grep -ir "string" . But that command searches inside all kinds of files, including binary files (pictures, ...
0
votes
0answers
15 views

How can I use zgrep to take a file with IPs and recursively search another path, then take matching lines and correlate them into a single txt file?

How can I use zgrep to take a file with IPs and recursively search another path, then take matching lines and correlate them into a single text file? The command I have been using to find a single IP ...
0
votes
1answer
58 views

GREP for multiple strings with wildcard

I am trying to copy lines from a log file from certain days. Here's an example of what they look like. 2014-05-01T15:53:16+00:00 DEBUG (7): 2014-04-301T11:08:10+00:00 DEBUG (7): This GREP ...
1
vote
1answer
42 views

Grep and What If 75

I'm trying to run the command from What if 75: cat wordlist.txt | perl -pe 's/^(.*)$/\L$& \U$&/g' | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' '2223334445556667777888999' | grep -P "(.)\1\1\1\1\1" I ...
3
votes
1answer
88 views

Using grep to filter output of a process

I'm using command | grep -v "JavaScript strict warning" to filter the output of a command (hiding warnings). The grep command works fine when I test it like this: $ printf "JavaScript strict warning: ...
1
vote
1answer
74 views

How to redirect ALL output from a command in Linux

I'm running Gentoo Linux. A program (equery) outputs a massive list of all the currently installed packages (equery list "*"). I want to find out which of them are unstable. Equery marks the unstable ...
1
vote
2answers
70 views

Tail and grep recursively?

Trying to tail though a list of domains to search for a hacker code. All the files that I'm looking for are the same so I was trying something like this: grep -rnl * -e "Ai9LbaFz7lC13SwzDxAYT72vwA" ...
0
votes
1answer
1k views

Recursive zgrep not working

I have a directory hierarchy that contains numerous .gz files. I want to be able to recursively grep them for the string "foo". From what I've read online the following should work: zgrep -R -H ...
1
vote
2answers
59 views

How to save linux command?

I am using grep -r [^a-zA-Z0-9]myVariableName[^a-zA-Z0-9] -n JS_files/ as mygrep file grep -r [^a-zA-Z0-9]$1[^a-zA-Z0-9] -n JS_files/ and then sh mygrep myVariableName But then I lose the ...
2
votes
3answers
131 views

What does really mean null string?

I'm sure most of us know that when we want that some regex matches with a string at the begin of the line we must use "^" ... But, I'm trying to understand what really means "empty string at the ...
0
votes
4answers
91 views

Count lines with alphabet in linux

I have a file with a number of lines in a file filename. I want to count how many lines start with character 'a', with 'b' and so on in one go. What command i should execute.?
0
votes
2answers
173 views

Writing a single line command that interprets conditional output from pdbedit

I would like to run a command on a single line that will tell me if the flag is set for a user's password to be changed on next login. This command will interpret the output and return a true/false. ...
0
votes
1answer
142 views

Find a pattern in a line, and append that matched pattern to the same line

I'm trying to pull a job number out of notes listed in a csv, and then append that number to the end of the line, preferably through sed, awk, grep or perl (which I have installed in Cygwin. Here's a ...
0
votes
2answers
115 views

Linux output line numbers where string match appears

what I'm looking to do is boost the command I already have to return line numbers of where the specified string appears: grep -r -l -n -w "ePKI" /home/websites/www/* > /home/keywords.txt The ...
0
votes
1answer
91 views

How can I open a set of files in sublime based on their contents

I am trying to find all the files that contain a search term: grep -lir "Search" . and pipe that into sublime: grep -lir "Search" . | subl but all this does is open a single file in sublime ...
0
votes
1answer
67 views

Search files for text matching format of a Unix directory

I am attempting to search through all the files in a directory for text matching the pattern of any arbitrary directory. The output of this I hope to use to make a list of all directories referenced ...
3
votes
2answers
1k views

Efficient way to search string within file find and grep

I am searching all files containing a specific string on a filer (on an old HP-UX workstation). I do not know where the files are located in the file system (there are many directories, with hudge ...
2
votes
3answers
283 views

How to use grep to search for regular expressions themselves, without parsing them

grep . filename.txt This just returns all of the contents in filename.txt, because . is a regular expression that stands for any character. How do I use grep to search for periods, or other regular ...
1
vote
2answers
280 views

netcat output into separate files using string delimiters

I want netcat to pipe the output of a tcp/ip connection to commands that examine the output and split it into distinct files separated by the strings "msg" and "/msg" from the output, something like ...
3
votes
1answer
3k views

Using grep to remove lines from a file which contain a string from another file

I have a file containing words (one per line) such as Dog Fish Cat Shoes I have a secondary file in CSV format such as 1,shoes,red 2,apple,black 3,fog,blue I would like to use grep with ...
0
votes
4answers
243 views

Extracting specific line of text with grep for use in conky

I'm trying to extract the directory of the current playing song in Quodlibet for use in attempting to display album artwork in conky. In QL's current file ~/.quodlibet/current there is a line that ...
2
votes
2answers
352 views

Grep default color option

grep is one of the most commonly used command in linux. It feels to me that its basic feature to highlight the string you searched for on the output lines. this can be achieved by --color option. ...
1
vote
2answers
247 views

Is there a better way to do this command to find strings in a file excluding special characters?

Is there a better way to do this command to find strings in a file excluding special characters? Currently I'm doing: strings file.abc | grep -v \= | grep -v \] | grep -v \) | more I'd like to add ...
6
votes
2answers
526 views

Why is the grep/-r/--include combination slower than the find/-exec/grep combination?

From my understanding, the two following commands roughly accomplish the same thing: Command 1: find -name "filename.xml" -exec grep someString {} \; Command 2: grep -r --include=filename.xml ...
2
votes
2answers
1k views

Command-line CSS selector tool

Question What tool (preferably for Linux) can select the content of an HTML element based on its CSS path? Example For example, consider the following HTML document: <html> <body> ...
16
votes
1answer
15k views

What is the difference between grep, pgrep, egrep, fgrep?

I'd like a walk through on the differences between grep, pgrep, egrep, and fgrep and how I would use them.
3
votes
4answers
1k views

Using grep to display second character in string?

I have a string that is always 3 characters... the first one and the last one are always the same. example: ▁▅█ Is there a simple way to only display the one in the middle? (which is the only one ...
5
votes
1answer
792 views

What does the grep switch --color=auto do?

What effect does auto as an option for the --color switch have in grep? When does grep decide to color the the matching strings, and when doesn't it?
0
votes
1answer
234 views

How to pipleline stderr in cmd.exe?

Some programs would prefer to output the help message in stderr. I want to search the help message with grep command, xx /? | grep regex? How could i do this?
4
votes
1answer
116 views

Running a command on all files that contain a string

I'm finding a bunch of files with find . -exec grep -l mypattern {} \; What's the simplest, most elegant way to run a certain command separately on each of the resulting list of files?
4
votes
2answers
2k views

Grep in Mac OS X's terminal — only displaying one color

I am used to grep being able to color the filename, the line number, and the match itself. These three ought to be different colors. This works flawlessly on a Linux terminal and even MinGW on ...
1
vote
3answers
4k views

Search for files and print their full path

ls -R /media/X | grep filename lets me search for file names, but it only prints the file name and not the directory it resides in. How can I print the file name and its directory?
1
vote
2answers
298 views

List all files in a directory matching a string and copy output

I'm trying to create a series of playlists on my MP3 player, running Rockbox, by finding a file matching a string, using find /cygdrive/g/MUSIC -type f -name "Search Criteria" | ...
1
vote
2answers
2k views

Get the most common appearing lines from file in Linux

I have a text file that has various words per line. How can I find the 12 most frequent appearing lines in the file and display them? I am not very good with scripting commands. If I could get the ...
0
votes
3answers
196 views

Count all files without using find

How can I count all files without using find and only grep? I tried using ls recursively but how can I pipe that to grep and count files?
0
votes
1answer
521 views

How to find the last match of a string in a bunch of files

I have a bunch of files, I'd like to find the last match of a string in each of them. grep text *.file gives me all the matches not the last ones. ls *.file | xargs grep text | tail -n 1 gives me ...
0
votes
2answers
1k views

How to use Grep in Unix command line?

I want grep all lines containing words that start with "H" and end with "d". How would i do that? I found that grep ^H will give me the H for everyline.
13
votes
2answers
8k views

Counting total number of matches with grep instead of just how many lines match

Does grep offer a way to count the total number of matches it makes? The -c option only returns the number of lines that matched the regex, but in this case I have multiple matches per line.
1
vote
3answers
196 views

How can I determine whether different commands using grep, find and xargs do the same thing?

Do these three commands do the same thing? A command that uses grep. grep "a" -r . A command that uses find. find . -exec grep "a" {} \; A command that uses a grep on a find through xargs. ...
1
vote
6answers
2k views

Finding files based on date, without using `find`

I know find can do what I am looking for, but I am wondering if there is an alternative way to find files on the filesystem either created before/after a certain point, or at a certain time. ...
7
votes
6answers
3k views

Using an index to make grep faster?

I find myself grepping the same codebase over and over. While it works great, each command takes about 10 seconds, so I am thinking about ways to make it faster. So can grep use some sort of index? I ...
40
votes
7answers
85k views

Command prompt (Windows 7) grep equivalent?

Is there a command prompt (Windows 7) grep equivalent? That is, I want to filter out the results of a command: Bash use: ls | grep root What would it be from a Windows command prompt?
3
votes
2answers
9k views

How to find file with name=“php.ini” on linux using grep command

How to find file with name="php.ini" on linux using grep command ? Can anybody show me ?
1
vote
1answer
666 views

How can the Windows Command Line do a grep -o?

Is there a way in Windows to get a matching string within a string? echo hereisastring | find "is" and just display is without using grep The following worked using FIND. credit to Hello71 ...