- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Korn Shell Script 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
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
11-12-2007 06:24 AM
11-12-2007 06:24 AM
Korn Shell Script Help
Kindly assist me.
I have output as per attached.
I need to extract FROZEN ID.
My output format should be as follow :
ID Status
006707 FROZEN
Thanks
-Kamarul
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-12-2007 06:35 AM
11-12-2007 06:35 AM
Re: Korn Shell Script Help
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-12-2007 06:36 AM
11-12-2007 06:36 AM
Re: Korn Shell Script Help
awk 'NR > 5 {print $1 "FROZEN"}' myfile.txt
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-12-2007 06:45 AM
11-12-2007 06:45 AM
Re: Korn Shell Script Help
Here is a possible solution:
$ cat x.pl
#!/usr/bin/perl
use strict;
use warnings;
my $id;
my $header=0;
#
# Read in all data lines from STDIN or first file mentioned.
#
while (<>) {
$id = $1 if /^(\d+)\s/; #Looks like an id? Remember it.
if (/FROZEN\s+$/) { # Line ends in 'FROZEN'?
print " ID Status\n" unless $header++;
print "$id FROZEN\n";
}
}
$ ./x.pl x
ID Status
006707 FROZEN
Enjoy,
Hein.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-12-2007 06:47 AM
11-12-2007 06:47 AM
Re: Korn Shell Script Help
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-12-2007 03:14 PM
11-12-2007 03:14 PM
Re: Korn Shell Script Help
The problem here is that the ID is on the first of a two line pair. Checking NR > 5 also fails because of the titles and the line with "FULL" and the first of the pair.
Sandman's solves those issues.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-12-2007 04:34 PM
11-12-2007 04:34 PM
Re: Korn Shell Script Help
Tim, I got the following output that not as expected.
cel8484_MHS:/home/sup01/FREEZE# awk 'NR > 5 {print $1 "FROZEN"}' media_freeze_v2.dat
005837FROZEN
17FROZEN
FROZEN
005842FROZEN
19FROZEN
FROZEN
006703FROZEN
15FROZEN
FROZEN
006704FROZEN
0FROZEN
FROZEN
006707FROZEN
6FROZEN
FROZEN
006710FROZEN
7FROZEN
Hein, great!! I got the output as I'm expected.
Thanks although I'm not familiar with perl but got the solution.
Sanman, also great. I got it & thanks.
Dennis, thanks for your reply.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-12-2007 07:28 PM
11-12-2007 07:28 PM
Re: Korn Shell Script Help
See the following:
http://forums1.itrc.hp.com/service/forums/helptips.do?#33
You can reopen by:
http://forums1.itrc.hp.com/service/forums/helptips.do?#41