- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: ShellScript help pl
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
10-24-2004 07:56 PM
10-24-2004 07:56 PM
I've the following file,
1 a
1 a
1 a
1 b
1 b
I want the following output:
1 a 3
1 b 2
Pl help
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-24-2004 08:15 PM
10-24-2004 08:15 PM
Re: ShellScript help pl
This script with filename as parameter
file=$1
sort -u $file|while read line
do
echo "$line"" "$(grep "$line" $file|wc -l)
done
For scripting see
http://www.shelldorado.com/
Steve Steel
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-24-2004 09:13 PM
10-24-2004 09:13 PM
Solution1 a
1 a
1 b
1 c
1 a
1 a
1 b
and *still* want
1 a 4
1 b 2
1 c 1
then use
cat
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-24-2004 10:48 PM
10-24-2004 10:48 PM
Re: ShellScript help pl
# perl -ne'$x{$_}++}END{for(sort keys%x){s/$/ $x{$_}/;print}' file
Enjoy, Have FUN! H.Merijn
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-24-2004 11:44 PM
10-24-2004 11:44 PM
Re: ShellScript help pl
awk 'BEGIN {getline x}{i++;if (x!=$0) {print x,i;i=0;x=$0}} END {print x, ++i}' sorted_input
BEGIN - preset last seen record value
loop - always count. if new value not equal to old then: print value &count and reset value & count
END - print final value & count
fwiw,
Hein.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-25-2004 02:24 AM
10-25-2004 02:24 AM
Re: ShellScript help pl
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-26-2004 03:43 AM
10-26-2004 03:43 AM
Re: ShellScript help pl
Steve's Solution works perfectly in all cases. It works in your file as well ashwin's file
Singaram