1. How to make grep select both lines using only a single 'grep' command
: We have an ASCII file called "ships" with lines in this format:
: ..... 3HO/3HA(PNTN) 4SD ..... [line 1]
: ..... 3HO/3HA 4SD ..... [line 2]
: . [line n]
: The stuff in the parenthesis (the string "PNTN") can change.
: Is there a single grep/egrep regular expression that can display
: both lines?
: I tried:
: 1. grep -i "3ho/3ha * 4s" ships, showed line 2 only
: 2. grep -i "3ho/3ha* 4s" ships , showed line 2 only
: 3. grep -i "3ho/3ha *4s" ships , showed line 2 only
: 4. grep -i "3ho/3ha(*) 4s" ships, showed nothing
: 5. grep -i "3ho/3ha(*) 4s" ships, showed nothing
: 6. grep -i "3ho/3ha(p*) 4s" ships, showed nothing
Remember that regular expressions and filename globbing are different things.
You were attempting filename globbing, when grep requires a regular expression.
grep -i "3ho/3ha.* 4s" grepp
The ".*" does what you were trying to do with the "*", which is match a string
of 0 or more characters.
Beirne Konarski | Subscribe to the Unicycling Mailing List
Kent State University | Unicycling Web Page:
"Untouched by Scandal" | http://nimitz.mcs.kent.edu/~bkonarsk/
2. moving from one drive to another
3. Use of grep and awk commands with iostat and mail commands
4. Linux news group
5. grep sTerm * | grep -v grep ???
6. change MAC address
7. tail | grep | grep | grep
8. Solaris Certification
9. TAR command 2GB limitation
10. Limitation on size of command-line arguments
11. TAR command 2GB limitation
12. grep command .sh_history
13. Do command when tail -f some_file | grep some_exp, matches?