- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Find words from a file
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Forums
Discussions
Discussions
Discussions
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-13-2010 04:23 AM
08-13-2010 04:23 AM
How can I find out all the words starting from 'd' and ending with 'g' from a file.
Thanks..
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-13-2010 04:35 AM
08-13-2010 04:35 AM
Re: Find words from a file
$ sed -e 's|[ ][ ]*|\n|g' -e 's|[.,:;||g'
(Between the '[' and ']' are a space and a TAB !)
Explanation: the sed will put all words on a single line, cutting out common reading-symbols. The grep will get all lines starting with a 'd' and ending with a 'g'.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-13-2010 04:40 AM
08-13-2010 04:40 AM
Re: Find words from a file
# grep -E -w "d.+g" file
The '-w' switch enables "word" mode for 'grep'. The regular expression matches a word that begins with "d", is followed by one or more characters, and ends with "g". See the manpages for more information.
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-13-2010 01:29 PM
08-13-2010 01:29 PM
Re: Find words from a file
This doesn't do what you expected. It matches a word that starts with "d" and any number of chars, then ends in a possibly different word with "g":
d sig
This may work better:
grep -E -w "d[A-Za-z_0-9]+g"
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-14-2010 08:08 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-14-2010 08:12 AM
08-14-2010 08:12 AM
Re: Find words from a file
Do you want the words separated or just the lines with the words?
JRF's and my solution does the latter.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-16-2010 06:47 PM
08-16-2010 06:47 PM
Re: Find words from a file
I was looking only for the words (not lines) starting and ending with specific letters.
This was served by using Raj's solution.