- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: data extraction from file - help
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
тАО12-18-2003 12:27 PM
тАО12-18-2003 12:27 PM
data extraction from file - help
First I need to find the line contating XRef. Then Extract the number 99 from that line into a variable. I will use that variable to create a New file. Following lines are there in the original file.
#! rnews 0
Newsgroups: xxx
From: xxx
Subject: xxx
Date: xxx
Path: linux-nntp!forums-master!forums-1-dub!forums-1-dub!forums-master.sybase.com!forums-1-dub.sybase.com
Xref: linux-nntp sybase.test.xml:99
zzzzzzzzzzzzzzzzzzzzz
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО12-18-2003 01:19 PM
тАО12-18-2003 01:19 PM
Re: data extraction from file - help
x=`awk -F : '/Xref/{print $3}'
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО12-18-2003 08:02 PM
тАО12-18-2003 08:02 PM
Re: data extraction from file - help
John.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО12-18-2003 08:12 PM
тАО12-18-2003 08:12 PM
Re: data extraction from file - help
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО12-18-2003 08:16 PM
тАО12-18-2003 08:16 PM
Re: data extraction from file - help
how about I do it with perl then
perl -n -e 'if(/Xref.+:(\d+)/){print "$1\n"}'
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО12-18-2003 09:54 PM
тАО12-18-2003 09:54 PM
Re: data extraction from file - help
# perl -nle'/^Xref.+:\s*(\d+)/&&print$1' file
in a real script, it could be as
--8<---
#!/opt/perl/bin/perl
while (<>) {
m/^Xref\s*:.*:\s*(\d+)/ or next;
print "$1\n";
}
-->8---
Enjoy, Have FUN! H.Merijn
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО12-18-2003 09:55 PM
тАО12-18-2003 09:55 PM
Re: data extraction from file - help
If it is always the 3rd column:
grep -i '^xref:' | cut -d: -f3
If it is always the last column:
awk -F: '/XRef/ {print $NF}'
Mind one thing: awk will not match any line now, because XRef != Xref, that's why I used the liberty to use the -i option to grep.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО12-18-2003 10:13 PM
тАО12-18-2003 10:13 PM
Re: data extraction from file - help
no points please :)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО12-19-2003 06:54 AM
тАО12-19-2003 06:54 AM
Re: data extraction from file - help
awk -F: '/XRef/ {print $NF}' filename > filename1
It writes correct output into filename2.
But if I put the same command on a script file named 1.csh and run it, it doesn't out the results into filename2.
Can some one help me why it doesn't work ???
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО12-20-2003 01:31 AM
тАО12-20-2003 01:31 AM
Re: data extraction from file - help
make a small correction, change:
XRef
to
Xref
regards,
John K.