grep a Unix command-line utility which searches input passed to it for lines matching a regular expression, and prints the results.
1
vote
1answer
13 views
Generate CSV/TXT file from named zone file
I am in need of generating a csv/txt file from a zone file on a named DNS server.
For examples I would like to generate a list of the hostname and IP from the zone file
From this
monkey A ...
0
votes
2answers
32 views
Why escaped single quote doesn't work in grep?
I am trying to match a string:
* * * * * /usr/local/bin/growlnotify -t 'helloTitle' -m 'helloMessage' -n 'myApp' -sw
with:
crontab -l | grep '^[^#].*/usr/local/bin/growlnotify.*\-n \'myApp\'.*$'
...
-5
votes
0answers
38 views
Is it possible to for a regular linux user to never use GREP? [closed]
I m relatively new in Linux user and always try to find ways not to use grep command.
Is it possible for regular users, never to use Grep and always use some other commands like "Find" and get the ...
1
vote
2answers
39 views
netcat output into separate files using string delimters
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
...
0
votes
2answers
45 views
Recursively list full absolute path of files with permissions in Linux
I have done a bit of searching online, and I am trying to find a way to recursively list all files with their absolute path and with their permissions. I want to do this so that I can grep out what I ...
0
votes
1answer
42 views
The outputs of ps and top do not match
I have a situation where I have a process, say script.pl (here it is), which seems to stick around in the output to ps auxw | grep script.pl, sometimes when load is heavy it sticks around for several ...
0
votes
2answers
37 views
How to grep all logged in users?
How to grep all the logged in users from a user list in Linux (Ubuntu) ?
So far I got to:
cat /etc/passwd | grep "/home" | cut -d: -f1
3
votes
1answer
49 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
48 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 ...
0
votes
3answers
38 views
Does Unix grep work faster with long or short search terms?
Is it faster to look for long or short search terms? Or does it affect speed at all? In other words, should you make search terms as exact as possible?
There are more than 100 000 files and each file ...
2
votes
2answers
50 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.
...
0
votes
2answers
39 views
How do I use grep to search subdirectories too?
How do I use grep to search subdirectories as well as the files in the current directory?
Thanks.
0
votes
4answers
35 views
Why “ grep * ” not working?
On these days learning linux, I found something confued me:
$ cat abcd
line One
line Two
line Three
$ cat abcd | grep *
$ _ //nothing greped
$ cat abcd | grep ""
line One
line ...
0
votes
1answer
31 views
Search files for regex and return which files contain matches
I searched everywhere but didn't find out how to return a file content that matches given words or a regex.
cat /tmp/*.txt | grep "strings"
0
votes
3answers
29 views
linux, filter and format grep results
I have a script which outputs (2 results shown here)
Tag: tag_453672
Path: /abc/hosts/server42/vol/tempfile.tmp
Server host: server42
Region: unix
Active: NO
View tag ...
0
votes
1answer
28 views
How to grep file with prefix pattern?
How can I grep for lines of a file wich start with a certain string?
For example, all lines with prefex 0x, where the file has the lines
0x002
0x003
abc
Output should be
0x002
0x003
0
votes
4answers
84 views
Regular expression to find senders IP using grep or other languages
I have input file that contains:
19:04:01.631948 IP (tos 0xc0, ttl 1, id 0, offset 0, flags [none], proto UDP (17), length 48)
181.173.82.61.1985 > 250.66.33.195.1985: HSRPv0-hello 20: ...
1
vote
3answers
64 views
Is it possible to open a file to a specific line number as formatted in grep -n results?
I often use grep with the -n option to list line numbers, e.g.
$ grep -n xyz .*
/ext1/acheong/foo/bar/a.cc:42: inline bool abc(int xyz);
/ext1/acheong/foo/bar/a.cc:43: inline bool def(int xyz);
...
1
vote
1answer
71 views
grep with colored output returns several empty lines
I have strange issue with grep (2.12-2, debian testing).
In some situations when I do something like this:
grep -rni '."spacer">.' . grep return me several empty lines:
If I add --color=none ...
3
votes
2answers
88 views
linux: is tree -i -f -L $depth supposed to be faster than find -maxdepth $depth?
I am querying specific directories to see if I find files with a specific pattern in them and I have been trying it with two different commands:
Standard find command:
find -L $unix_dir\*/ -maxdepth ...
0
votes
2answers
37 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 ...
4
votes
2answers
88 views
How to grep a section of a file in bash shell
How can I "grep" the lines between an occurrence of some string1 and the (Nth) occurrence of some string2.
e.g.
if the file has line:
A
B
C
D
E
F
G
B
C
E
Q
I want to get the lines in bold (those ...
1
vote
1answer
60 views
Ubuntu Linux: find files between specific times?
I found an SO called using Find/Grep to search files between specific time of day
Based on that and a Unix SE called Grep command to find files containing text string and move them I ended up with:
...
1
vote
1answer
54 views
How to Grep up to a certain character or String
I need to extract log data from many terrabytes worth of log files. The thing is, the data I need starts and ends with patterns I can identify, but the code between can be anything between 10 and 100+ ...
0
votes
1answer
69 views
Using find with -exec gzip and grep
I have a bunch of zipped up log files and I want to search them all for a string. I tried this but it's not working:
find ./ -name "*.log.zip" -exec gzip -dc {} | grep ERROR \;
It's giving me:
...
0
votes
3answers
77 views
Grep for This and NOT That in a File?
How can I grep for files in a directory structure that have this text
addDesignControlChangeNotification
but are missing this text
removeDesignControlChangeNotification
Thanks!
Note: I mean the ...
0
votes
3answers
78 views
How to combine find and grep to recursively search for str or str2 in *.html and *.php files from /home/smith/sourcecode?
How can i combine find and grep to search for str1 or str2, recursively, in all *.html and *.php files starting from a directory named /home/smith/source? The output only needs to list files (with ...
2
votes
2answers
31 views
How can I find the other copy of an image file?
I have an image file, and I know there's another copy of it somewhere in a directory or one of its ancestors, but it has a different, unknown file name, and there are thousands of images in this ...
1
vote
3answers
124 views
How to grep long string across multiple lines, without knowing where the newline is
I want to search for a specific string across multiple lines in a file and get the line in which the match was found.
However, my problem is, that the file contains one very long string, and not, ...
1
vote
2answers
67 views
Finding folders only
My harddrive is in a mess, so I decided to do a cleanup. As a part of this, I want to merge all folders containing music into one. What I want to do is, look for any *.mp3's and *.aac's on my drive ...
0
votes
2answers
20 views
Doubts in Grep to display file name along with content
Am using the following grep to match a particular pattern in grep.
grep xyz abc.txt
now while i run this command, if the pattern matched, am getting the line containing xyz
Output:
xyz is doing ...
0
votes
2answers
58 views
Vim hiding quickfix column / gutter
After running :vimgrep I'll get a column to the left that with indicators pointing at lines where things were found. After editing, how can I hide this quickfix column?
Let me know if the question is ...
0
votes
1answer
93 views
Terminal highlight error when compiling with a make file
I have a simple make file and I want to highlite the word or line that contains "error:" to make it easier to see.
I am SSH via Putty to the linux machine which may cause a problem but currently I ...
1
vote
1answer
73 views
How to ack-grep replace a string of multiple words
The following command replaces every occurence of the word from in any file of the current directory or its subdirectories with to:
ack-grep -l --print0 --text from | xargs -0 -n 1 sed -i -e ...
0
votes
2answers
12 views
Bash: accessing another users documents
Using bash scripting I am trying to access another's users documents and search for a word in a file, how would I do this?
1
vote
1answer
30 views
What is the output of option 'n' for a grep on a device?
If I do this:
grep -a -n 'test' /dev/sdb10
It will search on the device sdb10 at binary level for a string 'test'. I can see the output of 'n' option, but what does it represent? Is the device ...
0
votes
1answer
32 views
Why doesn't this xargs + grep combo work properly?
I have two files, team1.txt and team2.txt
team1.txt
===========
Alex
Bob
Charlie
David
team2.txt
===========
Alex
Charlie
Benjamin
Zed
Noah
I want to output the people who are in both team1 ...
2
votes
1answer
62 views
using grep -E with AND conditions (ex: (?=/fo)^(?=/mo))
I have little problem figuring out how to get a list of files that has:
string "/fo" in it
But does not have string "/mo"
I'm trying to figure out that in folder with lot of text files...
My ...
2
votes
2answers
27 views
Get everything on line but match with grep
I'm trying to get everything on the matched line excluding the match using grep.
If I have
#define VERSION 0.1
The command should echo
0.1
I saw this question, but I only want things on the ...
3
votes
1answer
76 views
Strange execution time for recursive grep
I'm on a Linux Ubuntu machine, grepping a large number of files. Can anyone explain these timings?
>time grep -nIr acct_margin *
[... 3 results ...]
real 0m0.555s
user 0m0.400s
sys ...
4
votes
3answers
78 views
Can bash consume the same fifo from two separate commands?
I have a huge data source that I'm filtering using some greps.
Here's basically what I'm doing right now:
#!/bin/bash
param1='something'
param2='another'
param3='yep'
echo $(avro-read /log/huge_data ...
1
vote
1answer
57 views
Subtract files from one another recursively between two similar directories
I'm trying to concoct a way to grab two (nearly identical) directories and show me the difference between all files in the two directories.
Looking for two different things:
1- List all files ...
0
votes
1answer
78 views
Bash: Grep regular expression failing to work
When using grep like so:
ps aux | grep 'processname' | awk '{print $2}'
The PIDs of processes withprocessname is returned. When using this:
ps aux | grep '^processname' | awk '{print $2}'
I'm ...
0
votes
1answer
97 views
Grep issue (match two strings on same line)
Here I have some grep command which is not working correctly:
cat file1.txt:
apples
Date: Sun, 24 Feb 2013 8:14:06 -0800
peaches melons
cherry sky cloud
green purple
yellow
cat file2.txt:
apples
...
1
vote
2answers
49 views
Grep “out” matching and n subsequent lines
Consider a log file which looks like this:
action A
detail 1
detail 2
detail 3
action X
detail 1
detail 2
action B
detail 1
action X
detail 1
detail 2
action C
Lines with "action [ABC]" may have ...
0
votes
1answer
153 views
Search & Replace Using Grep and Sed Command
I want to remove the weird / special characters from the bunch of text files. Here i used the following command to remove the weird characters but it gives me the error.
Command :
1) grep -lri -e ...
1
vote
3answers
219 views
Why doesn't piping grep output into xargs work with color?
I have a strange issue. My grep has colored output, and if I do something like this:
grep -lr '80' /etc/apache2/sites-available/|xargs ls
I got:
ls: cannot access ...
1
vote
1answer
62 views
Extended regular expression new line
I seem to match two things using extended regular expressions:
Newline. I have tried [ \n], [ \\n], both don't work
Negative lookahead for string "timeout". I have tried (?!timeout)
Can anyone ...
0
votes
3answers
139 views
Bash: Find and replace text strings
I figured this would be easy, but I'm overlooking something simple:
I have a text file called test. It contains, for example, the string Alfred Hitchcock. I want to replace this with Alfred\ ...
0
votes
1answer
26 views
grep returning wrong messages in GNOME Desktop(Linux)
I need to search a particular string inside a folder structure.
The File system contains multiple files, but i need to check only XML files.
I searched and tried the commands for Linux Recursive ...