- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - Linux
- >
- grep command
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
Discussions
Discussions
Forums
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
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
тАО04-18-2006 02:31 AM
тАО04-18-2006 02:31 AM
USERNAME:john.doe
EMAIL:jonh.doe@yahoo.com
ADDRESS:somewhere
PHONENUMBER:12345
USERNAME:john.doe
EMAIL:jonh.doe@yahoo.com
ADDRESS:somewhere
PHONENUMBER:12345
How do I grep the file so that the output will order the data in the following way:The output from grep should be:
1)USERNAME:john.doe
2)EMAIL:jonh.doe@yahoo.com
3)PHONENUMBER:12345
4)USERNAME:john.doe
5)EMAIL:jonh.doe@yahoo.com
6)PHONENUMBER:12345
Solved! Go to Solution.
- Tags:
- grep
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-18-2006 02:34 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-18-2006 02:34 AM
тАО04-18-2006 02:34 AM
Re: grep command
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-18-2006 02:35 AM
тАО04-18-2006 02:35 AM
Re: grep command
grep -v "^ADDRESS:" filename
-v prints all lines that don't match the pattern.
^ designates the pattern should be at the beginning of the line.
Jeff Traigle
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-18-2006 02:39 AM
тАО04-18-2006 02:39 AM
Re: grep command
Filters like 'grep' make one-pass through a file, and hence your output will occur in the order the matches appear in the input source.
You can do:
# grep -e USERNAME -e EMAIL -e PHONENUMBER filename
...and you will see the order you posted as ouput if that's the sequential order of the input file.
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-18-2006 02:45 AM
тАО04-18-2006 02:45 AM
Re: grep command
Is there any advantage from using grep -e to using egrep?
How do I number the lines followed by a bracket?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-18-2006 02:45 AM
тАО04-18-2006 02:45 AM
Re: grep command
egrep "USERNAME|EMAIL|PHONENUMBER"
Chan
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-18-2006 02:48 AM
тАО04-18-2006 02:48 AM
Re: grep command
0 points for this reply.
Rgds...Geoff
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-18-2006 02:53 AM
тАО04-18-2006 02:53 AM
Re: grep command
grep -v "^ADDRESS:" filename | while read LINE
do
echo "${INDEX})${LINE}"
INDEX=$((${INDEX}+1))
done
Jeff Traigle
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-18-2006 02:53 AM
тАО04-18-2006 02:53 AM
Re: grep command
On HP-UX 'grep -E' (uppercase!) provides the same features as 'egrep'.
http://www.docs.hp.com/en/B2355-60103/grep.1.html
Regards!
...JRF...