Sponsored Content
Top Forums Shell Programming and Scripting count and compare no of records in bash shell script. Post 302398303 by devtakh on Wednesday 24th of February 2010 07:38:02 AM
Old 02-24-2010
Code:
awk -F "," '$1 == "D"{cnt+=1};$1 == "T"{tot=$2}END{print "Total in T is:",tot;if(cnt = tot) print "Same count and Count number is:",cnt; else print "Total not equal",tot}' file


cheers,
Devaraj Takhellambam
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Count No of Records in File without counting Header and Trailer Records

I have a flat file and need to count no of records in the file less the header and the trailer record. I would appreciate any and all asistance Thanks Hadi Lalani (2 Replies)
Discussion started by: guiguy
2 Replies

2. UNIX for Dummies Questions & Answers

How to count the occurences of a specific word in a file in bash shell

Hello, I want to count the occurences of a specific word in a .txt file in bash shell. Can somebody help me pleaze?? Thanks!!! (2 Replies)
Discussion started by: mskart
2 Replies

3. UNIX for Dummies Questions & Answers

Bash script to extract spf records

Hello I am trying to generate a script to run on worldwide firewalls. I need the spf block for large sites like google, etc so I can essentially whitelist google sites for users. (Google here is just an example...) Right now I am just testing Bash oneliners to see how I can isolate the... (1 Reply)
Discussion started by: mbubb
1 Replies

4. Shell Programming and Scripting

Shell Script to compare files, check current date and count

Hello - I have written the following basic shell script to count files, compare files and look for a particular strings in a file. Problem 1: How do I define more than 1 file location? #!/bin/bash #this is a test script FILES=$(ls /home/student/bin/dir1, home/student/bin/dir2)... (0 Replies)
Discussion started by: DallasT
0 Replies

5. Shell Programming and Scripting

Shell script to count number of ~ from each line and compare with next line

Hi, I have created one shell script in which it will count number of "~" tilda charactors from each line of the file.But the problem is that i need to count each line count individually, that means. if line one contains 14 "~"s and line two contains 15 "~"s then it should give an error msg.each... (3 Replies)
Discussion started by: Ganesh Khandare
3 Replies

6. Shell Programming and Scripting

Script to count particular type of records

Hi, I have a huge file containing thousands of records which are of following pattern: TYPE1 { originNodeType : "IVR" originHostName : "AAIVR" originTransactionID : "01310559" originTimeStamp : "20110620192440+0530" hostName : "hhhh" voucher : '0'D rProfileID : "ZZZZ" Before {... (5 Replies)
Discussion started by: madhukar1anand
5 Replies

7. Shell Programming and Scripting

Nawk script to compare records of a file based on a particular column.

Hi Gurus, I am struggling with nawk command where i am processing a file based on columns. Here is the sample data file. UM113570248|24-AUG-11|4|man1|RR211 Alert: Master Process failure |24-AUG-11 UM113570624|24-AUG-11|4|man1| Alert: Pattern 'E_DCLeDAOException' found |24-AUG-11... (7 Replies)
Discussion started by: usha rao
7 Replies

8. Shell Programming and Scripting

Compare two files with different number of records and output only the Extra records from file1

Hi Freinds , I have 2 files . File 1 |nag|HYd|1|Che |esw|Gun|2|hyd |pra|bhe|3|hyd |omu|hei|4|bnsj |uer|oeri|5|uery File 2 |nag|HYd|1|Che |esw|Gun|2|hyd |uer|oi|3|uery output : (9 Replies)
Discussion started by: i150371485
9 Replies

9. Shell Programming and Scripting

Script to compare count of two csv files

Hi Guys, I need to write a script to compare the count of two csv files each having 5 columns. Everyday a csv file is recived. Now we need to compare the count of todays csv file with yesterday's csv file and if the total count of records is same in todays csv file and yesterday csv file out... (3 Replies)
Discussion started by: Vivekit82
3 Replies

10. Shell Programming and Scripting

UNIX Script required for count the records in table

Hi Friends, I looking for the script for the count of the records in table. and then it's containg the zero records then should get abort. and should notify us through mail. Can you please help me out in this area i am lacking. (5 Replies)
Discussion started by: victory
5 Replies
Slurm::Hostlist(3pm)					User Contributed Perl Documentation				      Slurm::Hostlist(3pm)

NAME
Slurm::Hostlist - Hostlist functions in libslurm SYNOPSIS
use Slurm; $hostnames = "node1,node[2-5,12]"; $hl = Slurm::Hostlist::create($hostnames); $cnt = $hl->count; $hl->push("node21,node[27-34]"); while($host = $hl->shift()) { print $host, " "; } print $hl->ranged_string(), " "; DESCRIPTION
The Slurm::Hostlist class is a wrapper of the hostlist functions in libslurm. This package is loaded and bootstrapped with package Slurm. METHODS
$hl = Slurm::Hostlist::new($str); Create a new hostlist from a string representation. Returns an opaque hostlist object. This is a CLASS METHOD. The string representation ($str) may contain one or more hostnames or bracketed hostlists separated by either `,' or whitespace. A bracketed hostlist is denoted by a common prefix followed by a list of numeric ranges contained within brackets: e.g. "tux[0-5,12,20-25]". To support systems with 3-D topography, a rectangular prism may be described using two three digit numbers separated by "x": e.g. "bgl[123x456]". This selects all nodes between 1 and 4 inclusive in the first dimension, between 2 and 5 in the second, and between 3 and 6 in the third dimension for a total of 4*4*4=64 nodes. If $str is omitted, and empty hostlist is created and returned. $cnt = $hl->count(); Return the number of hosts in the hostlist. $pos = $hl->find($hostname); Searches hostlist $hl for the first host matching $hostname and returns position in list if found. Returns -1 if host is not found. $cnt = $hl->push($hosts); Push a string representation of hostnames onto a hostlist. The $hosts argument may take the same form as in create(). Returns the number of hostnames inserted into the list, $cnt = $hl->push_host($hostname); Push a single host onto the hostlist hl. This function is more efficient than slurm_hostlist_push() for a single hostname, since the argument does not need to be checked for ranges. Return value is 1 for success, 0 for failure. $str = $hl->ranged_string(); Return the string representation of the hostlist $hl. ranged_string() will write a bracketed hostlist representation where possible. $host = $hl->shift(); Returns the string representation of the first host in the hostlist or `undef' if the hostlist is empty or there was an error allocating memory. The host is removed from the hostlist. $hl->uniq(); Sort the hostlist $hl and remove duplicate entries. SEE ALSO
Slurm AUTHOR
This library is created by Hongjia Cao, <hjcao(AT)nudt.edu.cn> and Danny Auble, <da(AT)llnl.gov>. It is distributed with SLURM. COPYRIGHT AND LICENSE
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.8.4 or, at your option, any later version of Perl 5 you may have available. perl v5.14.2 2012-03-16 Slurm::Hostlist(3pm)
All times are GMT -4. The time now is 06:57 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy