grep is a command-line tool for searching text patterns in files

learn more… | top users | synonyms

21
votes
6answers
652 views

How can I prevent 'grep' from showing up in ps results?

When I search for some process that doesn't exist, e.g. $ ps aux | grep fnord wayne 15745 0.0 0.0 13580 928 pts/6 S+ 03:58 0:00 grep fnord Obviously I ...
2
votes
3answers
42 views

Very strange behavior with grep and IFS

I'm having trouble using grep, the returned results are "n-empty", I mean without the 'n' character... This is the script sample : OLDIFS=$IFS IFS="\\n" i=$(grep -ril $1 *) echo $i IFS=$OLDIFS ...
1
vote
2answers
32 views

Search and replace full line in recursive files

I'm using: grep -n -H -o -R -e textword . List all file recursively under directory '.' with string 'textword' and show the file, line and only portion matching. I need to remove lines that ...
3
votes
2answers
57 views

How to adjust column width in Linux command output

When I used this command on Red Hat Linux /usr/sbin/ss -i I get the following output below: State Recv-Q Send-Q Local Address:Port ...
3
votes
2answers
47 views

Can I make grep treat escaped multiline as a single line?

How can I make tools like grep treat multilines escaped with a backslash as a long single line? Let's say I have some files that looks like this: testvar=test1 \ test2 \ test3 ...
5
votes
3answers
164 views

difference between .* and * in regular Expression

I've a file named "test" that contains linux Unixlinux Linuxunix it's linux l...x now when i use grep '\<l.*x\>' , it matches : linux it's linux l...x but when i use grep '\<l*x\>' ...
1
vote
3answers
74 views

Trying to remove all ids from an HTML file with grep

I'm trying to remove all id=" "s from an .html file but I'm not sure where I am going wrong. I tried using regular expressions but all I am getting is the .html file rendering in my Ubuntu terminal. ...
3
votes
1answer
79 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" ...
1
vote
2answers
93 views

Unix command for pattern matching

I want to count the number of words and print the matched pattern lines which matches exactly with following pattern: abc-ERROR: The input File contains: # abc-ERROR: xyxxkkfgfr # def-Error: ...
4
votes
3answers
66 views

Uniquely identifying java processes with same name

I have two java processes which run using the same file name, MyApp.jar (for example). /usr/java/latest/bin/java -jar MyApp.jar These jars exist in different places and use different ...
0
votes
1answer
32 views

(e)grep and atomic grouping [comprehension question]

I am trying to understand the correct use of »atomic grouping« a.k.a. »independent subexpressions« a.k.a. »non-backtracking subpattern« [this are the terms I found ...
3
votes
2answers
88 views

greedy and lazy regular expressions (comprehension question)

I am teaching myself regular expressions, and I got stuck at »greedy« vs. »lazy« repeatings. What I found out so far is that »greedy« means that the RegExp ...
2
votes
1answer
60 views

How can I get grep to work with “->” as the pattern?

I have this text in a file called temp: -rw-r--r-- 1 root root 15776 Oct 15 2010 dnd-copy -rw-r--r-- 1 root root 15776 Oct 15 2010 dnd-link -rw-r--r-- 1 root root 15776 Oct 15 2010 dnd-move ...
-8
votes
1answer
52 views

can anyone help me with this sed and grep? [closed]

(a) SED Given a file, replace all the sequences of 4 or more digits with the word "cat". (b) GREP Given a file, display all the lines starting with the word "cat" and ending with the ...
-4
votes
0answers
36 views

I am really confused with this command [closed]

What does this mean in Linux? '<([A-z][A-z0-9]*)\b[^>]*>(.*)</\1>'

1 2 3 4 5 24
15 30 50 per page