- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Shell Script Assistance
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
07-04-2005 12:35 AM
07-04-2005 12:35 AM
Need some Shell expertise help.
I have input file that contain 2 fields(started date & Size).
input file example:
Started Kbyte
29/6/05 9000
29/6/05 1000
29/6/05 4000
30/6/05 2000
30/6/05 7000
How could I total-up the Size(Kbyte) group by Started field.
TQ.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-04-2005 01:10 AM
07-04-2005 01:10 AM
Re: Shell Script Assistance
sum=0
grep -v Kbyte
do
sum=$((sum+num))
done
echo $sum
or
echo `grep -v Kbyte
Cheers
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-04-2005 01:18 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-04-2005 03:21 AM
07-04-2005 03:21 AM
Re: Shell Script Assistance
try this:
awk 'NR==1 {unit=$2;next}
{s+=$2}
END {printf("%s %s\n,s,unit)}' inputfile
mfG Peter
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-04-2005 04:18 AM
07-04-2005 04:18 AM
Re: Shell Script Assistance
to add the date:
awk 'NR==1 {unit=$2;next}
{s+=$2; date=$1}
END {printf("%s %s %s\n,date,s,unit)}' inputfile
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-04-2005 04:49 AM
07-04-2005 04:49 AM
Re: Shell Script Assistance
awk '
NR=1 {print $0;next;}
{a[$1]=+$2;}
END {
for ( i in a ) print i, a[i];
} | sort -n
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-05-2005 03:38 AM
07-05-2005 03:38 AM
Re: Shell Script Assistance
Another enhancement to the script,
How do I produce the output like this :
Started Kbyte Total
29/6/05 9000
29/6/05 1000
29/6/05 4000 14000
30/6/05 2000
30/6/05 7000 9000
TQ
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-05-2005 05:50 AM
07-05-2005 05:50 AM
Re: Shell Script Assistance
awk 'prev1!=$1{if (NR > 1) printf " %s",s;prev1=$1;s=0};END{printf " %s\n",s};{s=s+$2;printf "\n%s",$
0}'
HTH
Rod Hills
PS- Assign points as your peers have helped you...