Sponsored Content
Top Forums Shell Programming and Scripting count identical strings print last row and count Post 302435424 by dcfargo on Wednesday 7th of July 2010 10:02:08 AM
Old 07-07-2010
count identical strings print last row and count

I have a sorted file like:

Code:
Apple 3
Apple 5
Apple 8
Banana 2
Banana 3
Grape 31
Orange 7
Orange 13

I'd like to search $1 and if $1 is not the same as $1 in the previous row print that row and print the number of times $1 was found.

so the output would look like:

Code:
Apple 8 3
Banana 3 2
Grape 31 1
Orange 13 2

I'm very new and don't have any useful code suggestions. I would guess the logic should be about counting and then comparing the count to the previous count.

Last edited by vgersh99; 07-07-2010 at 11:04 AM.. Reason: code tags, PLEASE!
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

row count of all files with more than 0 byte

Hi, Is there any way to get count number of lines in all files which have more than o bytes in current directory for example : in /user/sri/ there are 3 files abc 0 bytes def 5 bytes ghi 10 bytes i need to get wc -l for all files which have > 0 bytes at a time ..is... (6 Replies)
Discussion started by: sri2005
6 Replies

2. UNIX for Dummies Questions & Answers

row count but only number part

hi i am pretty new to unix .i am ETL guy I need a unix script to take row count of a file and write it to another file the problem with wc-l is it include filename also wc -l abc.dat will give me like 1000 abc.dat i just want 1000 to be written can u just take 2 min to write a simple... (1 Reply)
Discussion started by: er_zeeshan05
1 Replies

3. Shell Programming and Scripting

script to take row count

hi i am pretty new to unix .i am ETL guy I need a unix script to take row count of a file and write it to another file the problem with wc-l is it include filename also wc -l abc.dat will give me like 1000 abc.dat i just want 1000 to be written can u just take 2 min to write a simple... (5 Replies)
Discussion started by: er_zeeshan05
5 Replies

4. Shell Programming and Scripting

row count of 60 files in one file

hi all plz some unix guy help me in this i have 60 files which will have some records i want to find the total number of records in all the 60 files like file1 has 60 and file2 has 70 record i want to sum all these and find total row count in 60 files (5 Replies)
Discussion started by: er_zeeshan05
5 Replies

5. Shell Programming and Scripting

Count the delimeter from a file and delete the row if delimeter count doesnt match.

I have a file containing about 5 million rows, in the file there are some records which has extra delimiter at random position. (we dont know the positions), now we have to Count the delimeter from each row and if the count of delimeter is not matching then I want to delete those rows from the... (5 Replies)
Discussion started by: Akumar1
5 Replies

6. Shell Programming and Scripting

To count distinct fields in a row

I have . dat file which contains data in a specific format: 0 3 892 921 342 1 3 921 342 543 2 4 817 562 718 765 3 3 819 562 717 761 i need to compare each field in a row with another field of the same column but different row and cont the... (8 Replies)
Discussion started by: Abhik
8 Replies

7. Shell Programming and Scripting

Count the number or row with same value in a column

This is the source file, we called it errorlist.out 196 server_a server_unix_2 CD 196 server_b server_win_1 CD 196 server_c server_win_2 CD 196 server_bd server_unix_2 CD 196 server_d server_unix_2 CD 196 server_es server_win_1 CD 196 ... (14 Replies)
Discussion started by: sQew
14 Replies

8. UNIX for Advanced & Expert Users

row count

Hi, I want a row count of a file incliding header and trailer If I do cat Filename | wc -l then I am only getting the row count excluding the header and trailer Buit I want the row count including Header and trailer Please help Many thanks in advance, Pragyan (3 Replies)
Discussion started by: prarat
3 Replies

9. Shell Programming and Scripting

Print text between 2 identical strings

hey, i m having a hard time trying to print only the first occurrence between 2 idenicale strings. for the following output: please help me im a noob please im a noob help me noob please help me im a noob please im a noob help me noob (3 Replies)
Discussion started by: boaz733
3 Replies

10. Shell Programming and Scripting

Row Count in .csv file

Hi, I have to find the count of rows starting with "E," in given a.csv file . Sample Data File. E,2333AED,A,MC3,25,31-MAY-18 E,2333AED,A,MC3,25,31-MAY-18 CYMC3 25AED 0000 E,2333CZK,A,MC3,25,31-MAY-18 CYMC3 25CZK 0000 E,2333EUR,A,MC3,25,31-MAY-18... (3 Replies)
Discussion started by: Prabhakar Y
3 Replies
ipsec_config(1M)														  ipsec_config(1M)

NAME
ipsec_config - add, delete, export, and show HP-UX IPSec configuration objects in the HP-UX IPSec configuration database SYNOPSIS
[operation [object_type]] DESCRIPTION
The command adds, deletes, exports, and shows HP-UX IPSec configuration objects in the HP-UX IPSec configuration database, If HP-UX IPSec is active and running, also updates the HP-UX runtime IPSec policy database and runtime IKE information (IKE policies and authentication records). You must be superuser to run The utility can operate in command-line mode or batch mode. In command-line mode, reads all input from the command line. In batch mode, reads add and delete operations from a file. Batch mode allows administrators to add and delete multiple configuration objects in one operation. HP-UX IPSec processes the operations in a batch file as a group. Batch mode is useful if you are adding or deleting configura- tion records that may affect other records. HP recommends that you use a batch file to add configuration information. A batch file provides a permanent record of the configuration data and can be used to re-create the configuration database. Separate command arguments using whitespace (blanks, tabs or newlines). Use a backslash line continuation character to continue command input on subsequent lines. Operations and Object Types The command supports the following operations: See ipsec_config_add(1M) for more information. See ipsec_config_batch(1M) for more information. See ipsec_config_delete(1M) for more information. See ipsec_config_export(1M) for more information. See ipsec_config_show(1M) for more information. object_type can be one of the following: Authentication records, which specify Internet Key Exchange (IKE) versions, authentication methods, identity information and preshared keys. Bypass addresses. security certificate for a Certificate Authority (used for IKE authentication with RSA signatures). Certificate Revocation List (CRL). A CRL contains a list of revoked X.509 security certificates. If you have a CRL, HP-UX IPSec check it during the IKE authentication process to verify that the remote system's security certificate is valid (not revoked). Certificate Signing Request (CSR), which the HP-UX IPSec administrator can submit to a Certificate Authority (CA) to request a signed X.509 security certificate. Host IPsec policies, which specify HP-UX IPSec behavior for processing IP packets when the local system is an end host. IKE version 1 (IKEv1) policies. IKE version 2 (IKEv2) policies. security certificate for the local system (used for IKE authentication with RSA signatures). Start-up options. Tunnel IPsec policies, which specify IPsec tunnel transform parameters. Configuring Objects In most HP-UX IPSec topologies, you must configure the following objects: o Host IPsec policies o Authentication records (IKE ID information and preshared keys) To establish IPsec security, you must also have an IKE version 1 (IKEv1) or IKE version 2 (IKEv2) policy. The HP-UX IPSec product installs a default IKEv1 policy and a default IKEv2 policy. You can use these default policies without modifications in many topologies. HP recommends that you use the following procedure to configure HP-UX IPSec: 1. Create a batch file to configure IPsec policies and authentication records. An IKEv1 or IKEv2 policy is also required, but in most cases you can use the default IKEv1 or IKEv2 installed with the product. If you want to configure host-to-host IPsec poli- cies and use IKE with preshared keys for IKE authentication, create a batch file to contain the following statements: See the command subsection in ipsec_config_add(1M) for syntax and usage information. If you are using HP-UX IPSec with certificates (RSA signatures) for IKE authentication, you must also use the following com- mands to configure certificates: You must enter the above commands at the command-line prompt. (You cannot specify them in an batch file). The command creates a certificate signing request (CSR). As an alternative, you can use a utility provided by the certificate vendor to create the CSR. 2. Test the syntax of your batch file by entering the following command: The option verifies the syntax without adding objects to the database. 3. If the syntax is correct, add the configuration information to the configuration database by entering the following command: 4. Start and verify HP-UX IPSec. Use the following command to start HP-UX IPSec: Generate network traffic that uses IPsec. Use the following command to verify operation: Verify that HP-UX IPSec has created Security Associations (SAs) with the appropriate systems. 5. Use the command to configure HP-UX IPSec to automatically start at system boot-up time. ipsec_config Help The displays help and usage information for the HP-UX IPSec operations. Use the following syntax to access help: [operation [option_type]] EXAMPLES
You have two systems, Apple and Banana Apple and Banana are not multihomed. You want to secure all telnet packets between the two systems using IPsec ESP with AES, authenticated with SHA-1. The IKE version is IKEv1. This is a private network, and you will allow all other packets to pass in clear text. You use the default IKEv1 policy. On Apple, you configure: o Two host IPsec policies o One authentication record The first host IPsec policy, telnetAB, secures outbound telnet connections (Apple is the telnet client). You do not need to specify the source argument, since it will default to any IP address and any port, and the telnet client port number is dynamically allocated. The second policy, telnetBA, secures inbound telnet connections (Apple is the telnet server). The authentication record specifies the preshared key value used with (Banana): The configuration on Banana is the mirror image of the configuration on Apple: AUTHOR
was developed by HP. FILES
configuration database. default profile file. SEE ALSO
ipsec_admin(1M), ipsec_config_add(1M), ipsec_config_batch(1M), ipsec_config_delete(1M), ipsec_config_export(1M), ipsec_config_show(1M), ipsec_migrate(1M), ipsec_policy(1M), ipsec_report(1M). HP-UX IPSec Software Required ipsec_config(1M)
All times are GMT -4. The time now is 02:03 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy