![]() |
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here. |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| How to search for capital letters | djdaniel3 | UNIX for Dummies Questions & Answers | 1 | 04-06-2008 10:05 AM |
| Search File for Specific Words | mevasquez | UNIX for Dummies Questions & Answers | 2 | 12-04-2007 04:31 PM |
| Search files that all contain 4 specific words | WoodenSword | Shell Programming and Scripting | 13 | 01-22-2007 06:57 AM |
| how to find capital letter names in a file without finding words at start of sentence | kev269 | Shell Programming and Scripting | 1 | 04-10-2006 10:35 PM |
| search for words in file | Agent_Orange | Shell Programming and Scripting | 4 | 10-25-2002 06:29 AM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
Hi,
I just want to search a file for any words containng a capital letter and then display these words only as a list I have been trying grep but to no has not helped.(im using the bash shell) |
|
||||
|
I still get the creeps when I see "for f in `cat file`", but let's not dwell on that. You might also want to explore whether your grep has an -o option. Code:
grep -o '[^ ]*[A-Z][^ ]*' capitals.txt |
|
||||
|
[^ ] means any character which is not whitespace, and * means zero to infinity of those (remember regular expressions are usually greedy, so it will match as many as it can). If you grep for just [A-Z] then it will only print the actual uppercase characters; extending the regular expression to cover any adjacent non-whitespace characters on both sides should get what you were looking for.
|
![]() |
| Bookmarks |
| Tags |
| regex, regular expressions |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|