Sponsored Content
Top Forums Shell Programming and Scripting Perl - Sort and Count foreach line Post 302518255 by pravin27 on Friday 29th of April 2011 03:41:21 AM
Old 04-29-2011
try this,
Code:
#!/usr/bin/perl
@strings = ("Shirt pants candy pants keychain",
"shirt shirt Candy gum sticker gum",
"flowers shirt candy card card");
foreach (@strings)
{
@flds=split;
foreach(@flds) {$hash{lc $_}++;}
}
print $_," " , $hash{$_},"\n" foreach keys(%hash);

This User Gave Thanks to pravin27 For This Post:
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Nested foreach in perl

I have two arrays @nextArray contains some files like \main\1\Xul.xml@@\main\galileo_integration_sjc\0 \main\1\PortToStorageDialog.xml@@\main\galileo_integration_sjc\0 . . . \main\1\PreferencesDialog.xml@@\main\galileo_integration_sjc\0 @otherArray contains some files like ... (2 Replies)
Discussion started by: nmattam
2 Replies

2. Shell Programming and Scripting

Perl line count if it matches a pattern

#!/usr/bin/perl use Shell; open THEFILE, "C:\galileo_integration.txt" || die "Couldnt open the file!"; @wholeThing = <THEFILE>; close THEFILE; foreach $line (@wholeThing){ if ($line =~ m/\\0$/){ @nextThing = $line; if ($line =~ s/\\0/\\LATEST/g){ @otherThing =... (2 Replies)
Discussion started by: nmattam
2 Replies

3. Shell Programming and Scripting

How to count using foreach

I have a simple csh script that has a simple foreach loop that goes over numbers, from 1 to 10: foreach n(1 2 3 4 5 6 7 8 9 10) ... end Now I want to expand the script to work on over a hundred consecutive n values. Obviously, typing all the numbers between 1 to 100 is an unreasonable... (7 Replies)
Discussion started by: mcbenus
7 Replies

4. Programming

PERL, search and replace inside foreach loop

Hello All, Im a Hardware engineer, I have written this script to automate my job. I got stuck in the following location. CODE: .. .. ... foreach $key(keys %arr_hash) { my ($loc,$ind,$add) = split /,/, $arr_hash{$key}; &create_verilog($key, $loc, $ind ,$add); } sub create_verilog{... (2 Replies)
Discussion started by: riyasnr007
2 Replies

5. Shell Programming and Scripting

awk: sort lines by count of a character or string in a line

I want to sort lines by how many times a string occurs in each line (the most times first). I know how to do this in two passes (add a count field in the first pass then sort on it in the second pass). However, can it be done more optimally with a single AWK command? My AWK has improved... (11 Replies)
Discussion started by: Michael Stora
11 Replies

6. Shell Programming and Scripting

PERL foreach & open not working together

My script is as below: my $tile_list = `egrep "FCFP_TILE_LIST.*=" ${BudgetDir}/tile.params | sed -e 's/FCFP_TILE_LIST//' | sed -e 's/=//'`; print "Tile List = ".$tile_list."\n"; my @tiles = split(/\s+/, $tile_list); $unconst_out = "${DestDir}/Unconstrained_ports.rpt"; $check_tim_out =... (2 Replies)
Discussion started by: kuchi7
2 Replies

7. Shell Programming and Scripting

Need perl or shell script to sort vertical lines to horizontal line in csv format

Need perl or shell script to sort vertical lines to horizontal line in csv format My file like below ------------------------- ================================================================================ PATH PINKY1000#I1-1-ZENTA1000-2#I7-1-ASON-SBR-UP-943113845 ... (4 Replies)
Discussion started by: sreedhargouda.h
4 Replies

8. Shell Programming and Scripting

Perl - line count of a file

Hi, I am quite new to perl scripting. I have a dat file (datFile) from which I am pulling only first column and saving the output to a new file (f). From that file (f) I am removing blank lines and saving it to new file (datFile1). I am able to get the count of $f file in variable $cnt. But... (4 Replies)
Discussion started by: Neethu
4 Replies

9. UNIX for Advanced & Expert Users

Sort words based on word count on each line

Hi Folks :) I have a .txt file with thousands of words. I'm trying to sort the lines in order based on number of words per line. Example from: word word word word word word word word word word word word word word word word to desired output: word (2 Replies)
Discussion started by: martinsmith
2 Replies

10. Shell Programming and Scripting

Print perl hash value in foreach loop

Experts - Any advice on how to get a hash value in a foreach loop? Values print correctly on standalone print statements, but I can't access value in foreach loop. See sample code below and thanks in advance. foreach my $z (sort keys %hash) { for $y (@{$hash{$z}}) { print "$z... (6 Replies)
Discussion started by: timj123
6 Replies
sc_auth(8)						    BSD System Manager's Manual 						sc_auth(8)

NAME
sc_auth -- SmartCard authorization setup script SYNOPSIS
sc_auth pair [-v] -u user -h hash sc_auth unpair [-v] [-u user] [-h hash] sc_auth pairing_ui [-v] [-f] [-s enable|disable|status] sc_auth identities sc_auth list [-v] [-u user] [-d domain] sc_auth changepin [-t tokenid] [-u] sc_auth enable_for_login -c class-id SYNOPSIS - legacy sc_auth accept [-v] [-u user] [-d domain] [-k keyname] sc_auth accept [-v] [-u user] [-d domain] -h hash sc_auth remove [-v] [-u user] [-d domain] sc_auth hash [-k keyname] DESCRIPTION
sc_auth configures a local user account to permit authentication using a supported SmartCard. Authentication is via asymmetric key (also known as public-key) encryption. sc_auth works with signing keys, but not encryption keys. sc_auth can perform the following actions: pair Associate a user with a public key. Because user's keychain will be modified to be unlockable by a key, SmartCard with that key must be present in the reader. The key to use has to be specified by its hash. unpair Remove association with a user and keychain. If no specific hash is provided, all associations with a user are removed. pairing_ui Enable, disable and force to display pairing dialog when card with unpaired identities is inserted identities List all identities on all SmartCards and display appropriate associations with users (for associated keys) or key names (for unas- sociated keys). list List all public keys associated with a user. changepin Change or unblock SmartCard PIN. This command works only for Personal Identity Verification (PIV) SmartCards. With -u argument, PIN can be unblocked using PUK and without the -u argument, PIN can be changed. Optional -t argument allows specifying tokenID. enable_for_login Enable the app extension for login and make the token available to the system for authentication. DESCRIPTION - legacy sc_auth can perform the following legacy actions: accept Associate a user with a public key on a card. The key to use can be specified either by its name or its hash. remove Remove all public keys associated with a user. hash Print the hashes for all keys on all inserted cards. OPTIONS
-u user Specifies the user whose account is to be modified -d domain Specifies the directory domain containing the user account -k keyname Specifies a public key by its name -h hash Specifies a public key by its hash -v Verbose mode -f Force to display pairing dialog -t tokenid Specifies a token by tokenID -c class-id Specifies a token by 'com.apple.ctk.class-id' from Info.plist NOTES
sc_auth is a shell script. It is intended to be modified by administrators to suit their local environments. sc_auth is only known to work with a local directory. Consult the script's source for some limited guidance to using remote directories. SEE ALSO
SmartCardServices(7), SmartCardServices-legacy(7), pam_smartcard(8) MacOSX December 11, 2006 MacOSX
All times are GMT -4. The time now is 11:09 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy