Sponsored Content
Full Discussion: List Counter
Top Forums Shell Programming and Scripting List Counter Post 302603224 by durden_tyler on Wednesday 29th of February 2012 10:41:04 AM
Old 02-29-2012
Code:
$
$ cat sport_by_month
Month : Jan
sport :Football
sport :Volleyball
Month: Feb
sport :BasketBall
sport: Cricket
sport: Fotball
Month: Mar
Month: APR
sport : Bowling
sport : Climbing
$
$
$ perl -lne '/^(\w+)\s*:\s*(\w+)$/;
             $1 eq "Month" ? do{$m=$2; $x{$m}=0} : $x{$m}++;
             END{print "$_  $x{$_}" for sort {$x{$a} <=> $x{$b}}(keys %x)}
            ' sport_by_month
Mar  0
Jan  2
APR  2
Feb  3
$
$

tyler_durden
 

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

counter in a variable - can it be done?

I have the following for(( i=1; 1<=2; i++)) do e1=123 n1=123 e2=456 n2=456 coord= $e1,$n1 echo "coordinate=$coord" done exit this echos coordinate=123,123 I need it to loop so: loop1 coord=$e1,$n1 loop2 (3 Replies)
Discussion started by: gazz1982
3 Replies

2. Shell Programming and Scripting

counter problem

Hi, I'm attempting to take the following input list and create an output file as shown below. I've monkeyed around for long enough. Can anyone help? NOTE: fs*** will be header and I want to get a count on NY**. fs200a NY7A fs200b NY7B NY7B NY7B fs200c NY7C NY7C NY7C NY7C... (2 Replies)
Discussion started by: jwholey
2 Replies

3. Shell Programming and Scripting

counter

Hi, I need some help. Shell script counter. i need to add condition to check if counter is more than 10 and longer than 3 hours? it runs every 5 mins. it only check count and send email right now. it runs in cron as below gregcount.ksh gregdb 10 > /tmp/gregcount.out 2> /tmp/gregcount.err ... (1 Reply)
Discussion started by: pega
1 Replies

4. Shell Programming and Scripting

grep and counter

Hi, I have such an example(ksh): name1=Example directory=/directory1/Example/directory2 match=$(grep -s '$name1' $directory | wc -l) echo $match But it replies to me: 0 What I expect from it, is to find $name1 in $directory and produce 1 for me as true, not false. (3 Replies)
Discussion started by: chish
3 Replies

5. Shell Programming and Scripting

DelimiterCount: how to use a counter

Hi, I am new to shell script. I want to count to Delimiter count for my source file. For that I have written script. When I tried to execute the script I could not able to view the results. It throws errors. I don't know what the problem is. My aim is I want to store the delimiter count in one... (4 Replies)
Discussion started by: suresh01_apk
4 Replies

6. Shell Programming and Scripting

problem with counter

i having a file xxxxxxxxxxxxxxx1234 ...........value can be change xxxxxxxxxxxxxxx1235 xxxxxxxxxxxxxxxx1236 . . . . xxxxxxxxxxxxxxxxx1300 ...........value can be change i want to cut last four characters of first line and last line and find the missing pattern. output should... (4 Replies)
Discussion started by: sagar_1986
4 Replies

7. Shell Programming and Scripting

Counter

if ;then echo "mrnet greater 5000" gzip /var/log/mrnet.log mv /var/log/mrnet.log.gz /var/log/mrnet.log.1.gz if ];then i=1 let i++ mv /var/log/mrnet.log.1.gz /var/log/vieux-logs/mrnet.log.$i.gz else echo "theres no... (1 Reply)
Discussion started by: Froob
1 Replies

8. UNIX for Dummies Questions & Answers

Pegging counter

Hi Experts, I am in need for some help. My competence level on unix is not at all helping me to resolve this. Please help. My Input for a system command is as under: Counters are getting pegged each hour. I need to have a difference printed rather than pegged counter values. Counter... (2 Replies)
Discussion started by: vanand420
2 Replies

9. Shell Programming and Scripting

Do i miss counter or what

hello this script should show all users and space they used without problem : ls /home >> /root/users.txt cat /root/users.txt | while read line; do space=`du -s /home/$line` echo "$line space is $space" shift done but when i remove pipe ,script run without any output: ls /home... (4 Replies)
Discussion started by: nimafire
4 Replies
nl_langinfo(3int)														 nl_langinfo(3int)

Name
       nl_langinfo - language information

Syntax
       #include <nl_types.h>
       #include <langinfo.h>

       char *nl_langinfo (item)
       nl_item item;

Description
       The  function  returns a pointer to a null-terminated string containing information relevant to a particular language or cultural area. The
       language is identified by the last successful call to the appropriate category.	The categories are shown in the following  table  and  are
       defined in

       For  instance,  the following example would return a pointer to the string representing the abbreviated name for the first day of the week,
       as defined by category
       nl_langinfo (ABDAY_1);

       If the category has not been called successfully, data for a supported language is not available, or is not defined, then returns a pointer
       to an empty (null) string.  In the C locale, the return value is the American English string defined in the following table:

       -----------------------------------------------------------------------
       Identifier   Meaning			    C locale	  Category
       -----------------------------------------------------------------------
       NOSTR	    Negative response		    no		  LC_ALL
       YESSTR	    Positive response		    yes 	  LC_ALL
       D_T_FMT	    Default date and time format    %a %b %d
						    %H:%M:%S %Y   LC_TIME
       D_FMT	    Default date format 	    %m/%d/%y	  LC_TIME
       T_FMT	    Default time format 	    %h:%m:%s	  LC_TIME

       DAY_1	    Day name			    Sunday	  LC_TIME
       DAY_2	    Day name			    Monday	  LC_TIME
       ....	    ....			    ....	  ....
       DAY_7	    Day name			    Saturday	  LC_TIME

       ABDAY_1	    Abbreviated day name	    Sun 	  LC_TIME
       ABDAY_2	    Abbreviated day name	    Mon 	  LC_TIME
       ABDAY_3	    Abbreviated day name	    Tue 	  LC_TIME
       ....	    ....			    ....	  ....
       ABDAY_7	    Abbreviated day name	    Sat 	  LC_TIME

       MON_1	    Month name			    January	  LC_TIME
       MON_2	    Month name			    February	  LC_TIME
       MON_3	    Month name			    March	  LC_TIME
       ....	    ....			    ....	  ....
       MON_12	    Month name			    December	  LC_TIME

       ABMON_1	    Abbreviated month name	    Jan 	  LC_TIME
       ABMON_2	    Abbreviated month name	    Feb 	  LC_TIME
       ....	    ....			    ....	  ....
       ABMON_12     Abbreviated month name	    Dec 	  LC_TIME

       RADIXCHAR    Radix character		    .		  LC_NUMERIC
       THOUSEP	    Thousands separator 			  LC_NUMERIC
       CRNCYSTR     Currency format				  LC_MONETARY
       AM_STR	    String for AM		    AM		  LC_TIME
       PM_STR	    String for PM		    PM		  LC_TIME
       EXPL_STR     Lower case exponent character   e		  LC_NUMERIC

       EXPU_STR     Upper case exponent character   E		  LC_NUMERIC
       -----------------------------------------------------------------------

See Also
       intro(3int), ic(1int), setlocale(3int), environ(5int), nl_types(5int)
       Guide to Developing International Software

																 nl_langinfo(3int)
All times are GMT -4. The time now is 07:56 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy