103.7 Search Text Files With Regular Expressions Flashcards

1
Q

Regular Expressions: grep

utility to find strings and phrases in
files
streams
directories

A

grep

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Regular Expressions: grep

count matches found only

A

grep -c

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Regular Expressions: grep

encloses the string match with # of lines of context before and after data

A

grep -C [#]

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Regular Expressions: grep

use the indicated extended regular expression for finding match

A

grep -E [ext. regex]

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

Regular Expressions: grep

use the indicated fixed regular expression for finding a match

A

grep -F [fixed regex]

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

Regular Expressions: grep

displays the filename of each matching string or phrase

A

grep -H

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

Regular Expressions: grep

prevents the filename from being displayed

A

grep -h

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

Regular Expressions: grep

ignore case

A

grep -i

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

Regular Expressions: grep

show only the filename and not the matched string/phrase

A

grep -l

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

Regular Expressions: grep

show only filenames that do NOT contain a match

A

grep -L

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

Regular Expressions: grep

match only lines containing the whole string or phrase

A

grep -w

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

Regular Expressions: grep

show only exact whole line matches to the entire string or phrase

A

grep -x

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

Regular Expressions: grep

show only those lines in a file that do NOT match the string or phrase (opposite of default)

A

grep -v

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

Regular Expressions: egrep

grep command without having to specify the -E that allows use of extended regular expression to match patterns of text

A

egrep

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

Regular Expressions: egrep

would display any entry in /etc/passwd file that starts with ope and then has either n or r as the next letter

A

egrep ^ope(n|r) /etc/passwd

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

Regular Expressions: egrep

would display any lines containing either bin or bash

A

egrep (bin|bash) /etc/passwd

17
Q

Regular Expressions: fgrep

grep command w/o having to specify the -F that allows use of a file that contains one or more items to search for

A

fgrep -f [itemfile]

18
Q

Regular Expressions: fgrep

will use items in itemfile.txt as search parameters for all lines in the searchfile.txt and display the matches

A

fgrep -f itemfile.txt searchfile.txt

19
Q

Regular Expressions: grep

all grep commands support ranges
[a-z] or globs(*)

A

as search parameters