Tagged Questions
1
vote
2answers
48 views
linux + match IP ADDRESS with 3 octets or with 4 octets
how to match IP address with 4 octets or with 3 octets in one command?
target - match xxx.xxx.xxx or xxx.xxx.xxx.xxx ( syntax should fit for Linux and Solaris )
how to merge the following commands ...
0
votes
2answers
52 views
Grep to search directories for patterns inside a text file
I have a file where it contains a list of search patterns (searchPattern.txt). Its contents is similar to the contents below where there are 3000+ of them.
123456
234567
345678
.
.
.
What I wanted ...
3
votes
1answer
89 views
Output of `java -version` not matched by grep or awk
On my Linux machine, it isn't clear to me why if I do the following then I don't get only the version string ("1.5.0_32").
# java -version | grep version | awk '{print $NF}'
java version "1.5.0_32"
...
0
votes
3answers
126 views
Regular Expression for finding double characters in Bash
I am looking for a regular expression that finds all occurences of double characters in a text, a listing, etc. on the command line (Bash).
Main Question: Is there a simple way to look for sequences ...
1
vote
2answers
131 views
Regular expression problem(s) in Bash: [^negate] doesn't seem to work
When I execute ls /directory | grep '[^term]' in Bash I get a regular listing, as if the grep command is ignored somehow. I tried the same thing with egrep, I tried to use it with double and single ...
1
vote
3answers
205 views
Newbie struggles with grep, sed, awk to filter html
I am a beginner linux user, trying to teach myself how to use linux tools on a cygwin install. I decided to make up a project to try to teach myself the basics of shell scripting and simultaneously ...
3
votes
5answers
127 views
Use grep to find all files in a directory with two strings [duplicate]
I am trying to figure out the correct syntax to find two strings, the entire part of each string, anywhere (doesn't have to be near each other) in a file. So any file that has both foo and say the ...
-1
votes
1answer
45 views
Doing regex in python [closed]
I had a directory "/pcap_test" which contains several log files. Each file has a pattern like:
Pkt: 1 (358 bytes), LIFE: 1, App: itunes (INTO), State: TERMINATED, Stack: /ETH/IP/UDP/itunes, Error: ...
3
votes
5answers
158 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 ...
0
votes
2answers
137 views
Sample file for grep
Can anyone please point to some good sample files that helps to learn grep. This is for academic use. It should be a large one so that students could understand its importance
1
vote
1answer
129 views
solaris + fit egrep for solaris
On Linux machines I use this syntax, in order to match all VALID ip's.
My question: what needs to change for egrep command in order to run the egrep on Solaris?
According to egrep manual page "-o" ...
1
vote
1answer
108 views
questions on find and grep
With respect to the following find command-line
find . -type f -exec grep -l strings {} \;
I do not understand the usage of -exec and {} \ Thanks.
1
vote
3answers
787 views
Linux: Does find | xargs grep have limitations?
I've historically performed something like:
find . 2>/dev/null | xargs grep -i something_to_find 2>/dev/null
If my pwd is barfoo (/foo/bar/baz/foofoo/foobar/foobaz/barfoo) it finds matches. ...
1
vote
3answers
96 views
Finding out how many programs I have not installed from a list with grep/awk in archlinux
I want to see how many packages from a list are not installed. I use archlinux, so I use pacman -Q to determine if a package is installed. If it is not installed, it returns a message like: "error: ...
0
votes
2answers
233 views
Removing a long string from php files - using grep and sed?
I have encountered some malware on my Linux server, and am trying to remove it from many php files.
I've tried endlessly with grep | sed and grep | tr and couldn't even erase a simple text string, ...
7
votes
8answers
3k views
How can I “cat” a file and remove commented lines?
I'd like to know if there is a way that I could cat file like php.ini and remove all lines starting with ;
For example, if the file contained this:
; - Show all errors, except for notices
;
...
-2
votes
1answer
173 views
Linux “rpl” command doesn't replace text [closed]
I'm using rpl program in linux to replace date( with pdate( in some files.
But it says A Total of 0 matches replaced in 1 file searched.
while grep output for date( is:
...
0
votes
1answer
196 views
What does ^> mean in a grep pattern?
What does this command do?
grep "<[^>]*>" inuux.xml
What is searching for?
4
votes
1answer
593 views
What does \bi\b mean in a grep pattern?
What does this command do?
grep "\bi\b" linux.txt
What is it searching for?
4
votes
4answers
2k views
How to search for a word in entire content of a directory in linux
need to search for something in entire content
I am trying:
find . | xargs grep word
I get error:
xargs: unterminated quote
How to achieve this? Thanks.
0
votes
3answers
172 views
Use “grep” to match text in multiple files
I have data in multiple files. I want to find some text that matches in all files. Can I use the grep command for that? If yes then how?
1
vote
4answers
583 views
tee and grep at the same time (shell)?
I'm trying to run a server that writes to $log (a txt file) and then find all the text in the logfile that starts with '[1]' and put it in another file. Here's my attempt. tee -a $log works along with ...
2
votes
2answers
116 views
How costly is case insensitive search as compared to case sensitive search?
I dont think grep -i is exponentially (wrt to the number of characters to be grepped) more costly (time wise) than a normal grep because the run times are not too different.
But theoretically it ...
5
votes
1answer
105 views
Search for a text in Linux but don't display the complete line in results
I'm using grep to do this, like:
grep someText file.log
But this returns the complete line in results. If someText is found in the middle of a line I don't want to ouput the whole line, just the ...
22
votes
2answers
2k views
Does grep use a cache to speed up the searches?
I have noticed that subsequent runs of grep on the same query (and also a different query, but on the same file) are much faster than the first run (the effect is easily noticeable when searching ...
6
votes
4answers
3k views
Finding a substring in files across subdirectories with a single built-in command?
In Windows, if I wanted to find a string across all files in all subdirectories, I would do something like
findstr /C:"the string" /S *.h
However, in Linux (say, Ubuntu) I have found no other way ...
2
votes
0answers
259 views
How to generate a report summary of messages that triggered a specific DSN code
I use Sendmail on CENTOS 5.x,
I hope this is a simple question. =) I need to generate a report summary of messages that triggered a specific DSN code. For example:
Jan 11 07:43:34 server-example ...
