How do I list 'WORDS' containing a specific character? awk,sed,grep?
I have a large file containing thousands of lines, I want to list only strings containig "::".
File example: Data::Compare 1.22 (1.2101 < 1.22):: Data::Dumper::Concise 2.020 (1.100 < 2.020) Hash::Merge 0.12 (0.10 < 0.12):: Path::Class 0.18 (0.16 < 0.18):: Service-now INC10056109 Install Perl Sort::Topological module Primary 0.02 5.8.8, 5.14.0 TESTING :: String::Escape 0:: String::Escape 0:: Data::Compare 0:: ---------------------- Expected output: Data::Compare Data::Dumper::Concise Hash::Merge Path::Class Sort::Topological How can I achieve it? |
What about the line starting with Service? It does contain :: Or the one starting with Path?
What's wrong with it? You need to be more specific |
Quote:
|
Try:
Code:
awk '$1 ~/::/ {print $1}' file |
My solution above may work or may not. It's not exactly what I think you're after.
Is that what you want? Code:
Data::Compare |
Many thanks.. That is exactly what I wanted. :)
|
What about that:
Code:
awk '{for (i=1;i<=NF;i++) if ($i ~/[a-z]::/) print $i}' file |
Quote:
Try the solution from post #7 |
How about a little gem (pun):
Code:
ruby -ne 'puts $_.scan(/(\w+(::\w+)+)/)[0][0]' file |
thank you all
|
Code:
$ grep -Eo '\b[^ ]+::[^ ]+\b' inputfile.txt If you go into the advanced editing box, there's also an option allowing you to turn off the smiley faces. |
All times are GMT -5. The time now is 09:02 PM. |