- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Here is a tough one for the language guru's
Categories
Company
Local Language
Forums
Discussions
Knowledge Base
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Knowledge Base
Forums
Discussions
- Cloud Mentoring and Education
- Software - General
- HPE OneView
- HPE Ezmeral Software platform
- HPE OpsRamp
Knowledge Base
Discussions
Forums
Discussions
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
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
02-14-2003 12:09 PM
02-14-2003 12:09 PM
Gffff Rrrrrr gredwds@zzzzioon.com
fzzzzzan@zzz.zzzz.edu
JJJJ CCCCCC (E-mail) abcdefr99@prodigy.net
afjdl@turkey.com bcdade@aol.com
what I need to get down to is just beable to extra the email addresses as the final result from each line, some lines might have more than one address all the extra stuff can be trashed.
so my final output file will look like this
gredwds@zzzzioon.com
fzzzzzan@zzz.zzzz.edu
abcdefr99@prodigy.net
afjdl@turkey.com
bcdade@aol.com
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-14-2003 12:20 PM
02-14-2003 12:20 PM
Re: Here is a tough one for the language guru's
Try this
for i in $(cat your_logfile)
do
echo $i |awk '/\@/ {print $0}'
done
Downside of it is that it is going to print every word that has @ in it if it is ok with you
-Sri
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-14-2003 12:24 PM
02-14-2003 12:24 PM
Re: Here is a tough one for the language guru's
$ cat logfile|tr " " '\012'|grep @ > newlogfile
assuming the "extra stuff" does not have any "@" character.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-14-2003 12:30 PM
02-14-2003 12:30 PM
Re: Here is a tough one for the language guru's
awk -F " " '{print $NF}' > /tmp/new_file.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-14-2003 12:31 PM
02-14-2003 12:31 PM
Re: Here is a tough one for the language guru's
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-14-2003 12:36 PM
02-14-2003 12:36 PM
SolutionWhatelse kind of data you have?
-Sri
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-14-2003 12:36 PM
02-14-2003 12:36 PM
Re: Here is a tough one for the language guru's
I beg to differ, but Sri's answer (with only a minor modification) works perfectly.
for i in `cat yourlogfile`
> do
> echo $i |awk '/\@/ {print $0}'
> done
Pete
Pete
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-14-2003 12:40 PM
02-14-2003 12:40 PM
Re: Here is a tough one for the language guru's
#!/bin/ksh
while read LINE
do
for WORD in $LINE
do
echo $WORD | grep -q "@"
if [ $? -eq 0 ]
then
echo $WORD
fi
done
done < YOUR_FILE_HERE
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-14-2003 12:49 PM
02-14-2003 12:49 PM
Re: Here is a tough one for the language guru's
# awk '{for (i=1; i<=NF; i++) if ($i ~/@/) {print $i}}' filename
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-14-2003 12:50 PM
02-14-2003 12:50 PM
Re: Here is a tough one for the language guru's
This modified script should work as well.
#!/bin/ksh
while read LINE
do
for WORD in $LINE
do
if [[ $WORD = *@* ]]
then
echo $WORD
fi
done
done < YOUR_FILE_HERE
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-14-2003 12:59 PM
02-14-2003 12:59 PM
Re: Here is a tough one for the language guru's
OK Let me make it more complicated so that if you find any word that says "alksdjf@asdkj", it should ignore it. Try this.
#!/usr/bin/ksh
DATA=j
for i in $(cat $DATA)
do
echo $i |awk '$0 ~/.*\@.*\../ {print $0}'
done
-Sri
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-14-2003 01:03 PM
02-14-2003 01:03 PM
Re: Here is a tough one for the language guru's
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-14-2003 01:10 PM
02-14-2003 01:10 PM
Re: Here is a tough one for the language guru's
I am being honest here for future reference.
You should be using JRF's script. I used for in shell and called awk for each value. JRF called "for" in awk's own umbrella. That will be much faster and effective.
-Sri
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-14-2003 01:11 PM
02-14-2003 01:11 PM
Re: Here is a tough one for the language guru's
I think if you time the solutions you will find that the pure 'awk' performs better than the 'cat'.
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-14-2003 01:16 PM
02-14-2003 01:16 PM