- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - Linux
- >
- Re: Organize data
Operating System - Linux
1753973
Members
8396
Online
108811
Solutions
Forums
Categories
Company
Local Language
юдл
back
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
юдл
back
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
Blogs
Information
Community
Resources
Community Language
Language
Forums
Blogs
Go to solution
Topic Options
- 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-15-2008 07:44 PM
тАО01-15-2008 07:44 PM
Re: Organize data
You can try the following. If you don't care about stable sorts, you don't need that nl(1):
# number lines if stable sort needed
nl -ba -nrz file | sort -k2,2 -k1n,1n | awk '
BEGIN { LAST="" }
{
if ($2 != LAST) { # list header
if (LAST != "") print "===="
print $2
LAST = $2
}
# print rest of line
for (i = 3; i < NF; ++i) printf $i " "
print $NF
}
END { print "====" } '
# number lines if stable sort needed
nl -ba -nrz file | sort -k2,2 -k1n,1n | awk '
BEGIN { LAST="" }
{
if ($2 != LAST) { # list header
if (LAST != "") print "===="
print $2
LAST = $2
}
# print rest of line
for (i = 3; i < NF; ++i) printf $i " "
print $NF
}
END { print "====" } '
- Tags:
- nl
- stable sort
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО01-16-2008 01:58 AM
тАО01-16-2008 01:58 AM
Re: Organize data
Hi Andre,
this run fine on my HPUX11i:
#!/usr/bin/ksh
sort your_file -o temp_file
for key in $(cut -d " " -f1 temp_file|uniq)
do
echo $key
grep "^$key " temp_file| cut -c 3-
echo "="
done
rm temp_file
HTH,
Art
this run fine on my HPUX11i:
#!/usr/bin/ksh
sort your_file -o temp_file
for key in $(cut -d " " -f1 temp_file|uniq)
do
echo $key
grep "^$key " temp_file| cut -c 3-
echo "="
done
rm temp_file
HTH,
Art
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО01-16-2008 04:51 AM
тАО01-16-2008 04:51 AM
Re: Organize data
Hi again guys,
I wanna thank you for the replies, now I have a lot of ideas to my script, all these answers works very very well.
Finally, thanks to Dennis and Arturo for the simple scripts.
You are great... This foruns help much more than a lot of books.
Andr├Г┬й
I wanna thank you for the replies, now I have a lot of ideas to my script, all these answers works very very well.
Finally, thanks to Dennis and Arturo for the simple scripts.
You are great... This foruns help much more than a lot of books.
Andr├Г┬й
Andre Augusto
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО01-16-2008 04:52 AM
тАО01-16-2008 04:52 AM
Re: Organize data
Close
Andre Augusto
- « Previous
-
- 1
- 2
- Next »
The opinions expressed above are the personal opinions of the authors, not of Hewlett Packard Enterprise. By using this site, you accept the Terms of Use and Rules of Participation.
News and Events
Support
© Copyright 2024 Hewlett Packard Enterprise Development LP