- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Hp-ux B.11.11 ksh Scripting .
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
01-31-2005 07:34 PM
01-31-2005 07:34 PM
Hp-UX B.11.11 U 9000/800 /usr/bin/ksh
file name: marks.txt
93 Steeve
72 Brocar
43 Minsen
22 Wilsen
77 David
99 Terence
82 Dave
89 Stuwart
78 Vivek
89 Paul
93 Ravi
95 Richard
How to write a script for that ,
I want listing of those name , who is greater than 80.
Does awk or sed help me.
Many Thanks in Advance,
Raj.
----
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-31-2005 07:39 PM
01-31-2005 07:39 PM
Re: Hp-ux B.11.11 ksh Scripting .
Regds,
Kaps
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-31-2005 08:04 PM
01-31-2005 08:04 PM
Re: Hp-ux B.11.11 ksh Scripting .
Hey Kapil ,
Thanks , thats works fine.
but can i save the result in a file.
Do i need to do >> or can i use something inside awk.
Thanks so much ,
RajD.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-31-2005 08:28 PM
01-31-2005 08:28 PM
Re: Hp-ux B.11.11 ksh Scripting .
Btw. the prepending cat is redundant.
Since TIMTOWTDI here's a Perl variant that will give you a sorted list of top seats exceeding 80 points
perl -e 'map{printf"%s\t%u\n",@{$_}[1,0]}sort{$b->[0]<=>$a->[0]}grep $_->[0]>80,map[/(\d+)\s+(\w+)/],<>' /path/to/inputdata
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-31-2005 08:31 PM
01-31-2005 08:31 PM
Re: Hp-ux B.11.11 ksh Scripting .
Regds,
Kaps
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-01-2005 10:21 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-02-2005 06:02 AM
02-02-2005 06:02 AM
Re: Hp-ux B.11.11 ksh Scripting .
I like "read":
cat test.in | \
while read a b
do
if [ $a -ge 80 ] ; then
echo $a $b
fi
done | \
sort -n
Good luck,
Bob
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-07-2007 10:42 PM
03-07-2007 10:42 PM
Re: Hp-ux B.11.11 ksh Scripting .
while read rank name; do
if [ $rank -gt 79 ]; then
echo "${rank} ${name}"
fi
done
Note for awk:
no need to cat the input file
awk '{ if ($1 > 79) print $2}' input_file > output_file
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-08-2007 12:07 AM
03-08-2007 12:07 AM
Re: Hp-ux B.11.11 ksh Scripting .
Using 'cat' to read and then piping its output to 'awk' or a shell 'read' loop is a needless, utter *waste* of a process.
Instead of:
# cat filename|awk '{if ($1 > 79) print $2}'
Do:
# awk '{if ($1 > 79) print $2}' filename
Instead of:
# cat file | \
while read a b
do
...
done | sort
Do:
# while read a b
do
done < file | sort
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-08-2007 01:08 AM
03-08-2007 01:08 AM
Re: Hp-ux B.11.11 ksh Scripting .
@Gordon, @Stefan: what about
100 Gordon
in connection with '/[89]...' ?
I fell better with the compare operator '>'.
mfG Peter