Sponsored Content
Top Forums Shell Programming and Scripting Shell script to count number of ~ from each line and compare with next line Post 302457876 by Ganesh Khandare on Wednesday 29th of September 2010 02:27:24 AM
Old 09-29-2010
MySQL Need something more in this script

Hi Jim,
Thanks your script is working fine.But i have one more problem like. your script every time goes into else loop. eve if oldsum is not eqal to sum then also its giving an error in count. i am getting result as below.

output----
Code:
error in  INTELLECT~EUR~EOD~40140~2010-09-21 00:19:20~20100920~~~~~~~~~  at line    tilde count= 14 
error in  INTELLECT~EUR~EOD~40140~2010-09-21 00:19:20~20100920~~~~~~~~~  at line    tilde count= 14

I need to cout number od tilda and if the count is not equal then it should give an error count are not equal. e.g
Code:
line 1 count= 14
line 2 count= 15

then it should give error msg like line 1 and 2 are not same also i dont want line to be print only count need.
also what is FNR i didnt get it. I am weak in awk script.
could you please reply me if possible. My Boss is shouting on me how much time you are taking to solve this problem.

Thanks & Regards,
Ganesh

Last edited by Scott; 10-04-2010 at 11:24 AM.. Reason: Code tags
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Compare number of line

Hi expert, I using csh and i trying to compare no. of line of the file. Example: I have 2 files. file1 ONE TWO THREE FOUR FIVE file 2 ONE TWO THREE FOUR file1 have 5 lines but file2 have 4 lines. (1 Reply)
Discussion started by: vincyoxy
1 Replies

2. Shell Programming and Scripting

current line number in shell script

Hi I am using korn shell is there a built in or ny other way to get the current line number so i can write the current line number to the logfile to aid in debugging like logmsg $lineno $date logmsg is a helper function that helps in logging messages to a log file regards (3 Replies)
Discussion started by: xiamin
3 Replies

3. Shell Programming and Scripting

[ask]how to compare line number

dear all, i need help about this case i have line number extract in file fileA.txt like this: 231 123 444 231 213 ... now i want to compare the line number fileA.txt to find other file in fileB.txt exp: if i use one by one like this: cat fileB.txt | sed -n -e "444"p huff...is not... (3 Replies)
Discussion started by: zvtral
3 Replies

4. Shell Programming and Scripting

How to read from specific line number in shell script?

I have a text file which is having 30000 lines in it. I have to create a xml file for each 10000 lines until all the lines in the text files are written. Also please help how can i get number of lines in the text file in a shell variable? (19 Replies)
Discussion started by: vel4ever
19 Replies

5. Shell Programming and Scripting

how to read the contents of two files line by line and compare the line by line?

Hi All, I'm trying to figure out which are the trusted-ips and which are not using a script file.. I have a file named 'ip-list.txt' which contains some ip addresses and another file named 'trusted-ip-list.txt' which also contains some ip addresses. I want to read a line from... (4 Replies)
Discussion started by: mjavalkar
4 Replies

6. Shell Programming and Scripting

Count number of occurrence at each line

Hi I have the following file ENST001 ENST002 4 4 4 88 9 9 ENST004 3 3 3 99 8 8 ENST009 ENST010 ENST006 8 8 8 77 8 8 Basically I want to count how many times ENST* is repeated in each line so the expected results is 2 1 3 Any suggestion please ? (4 Replies)
Discussion started by: fuad_
4 Replies

7. Shell Programming and Scripting

Want to count the number of lines after the first line

hi, How can i count the number of lines after the first line in a flat file in unix? Say i have a flat file with a header like: Student Name Student ID .... Tnx (7 Replies)
Discussion started by: reignangel2003
7 Replies

8. Shell Programming and Scripting

Compare file1 header count with file2 line count

What I'm trying to accomplish. I receive a Header and Detail file for daily processing. The detail file comes first which holds data, the header is a receipt of the detail file and has the detail files record count. Before processing the detail file I would like to put a wrapper around another... (4 Replies)
Discussion started by: pone2332
4 Replies

9. Shell Programming and Scripting

Count the pipes "|" in line and delete line if count greter then number.

Hello, I have been working on Awk/sed one liner which counts the number of occurrences of '|' in pipe separated lines of file and delete the line from files if count exceeds "17". i.e need to get records having exact 17 pipe separated fields(no more or less) currently i have below : awk... (1 Reply)
Discussion started by: ketanraut
1 Replies

10. Shell Programming and Scripting

Get the line number in shell script

I have one text file 1 2 3 a 5 4 4 3 where i want to print the line number while read line do line_no=`awk '{print NR, $0}'` echo 'In line no $line_no' done <$txt_file If i run the above code, it will print 'In line no 1 1 2 3' It prints the line number with the whole... (3 Replies)
Discussion started by: RJG
3 Replies
STRING(3)						     Library Functions Manual							 STRING(3)

NAME
strcat, strncat, strcmp, strncmp, strcasecmp, strncasecmp, strcpy, strncpy, strlen, index, rindex - string operations SYNOPSIS
#include <strings.h> char *strcat(s, append) char *s, *append; char *strncat(s, append, count) char *s, *append; int count; strcmp(s1, s2) char *s1, *s2; strncmp(s1, s2, count) char *s1, *s2; int count; strcasecmp(s1, s2) char *s1, *s2; strncasecmp(s1, s2, count) char *s1, *s2; int count; char *strcpy(to, from) char *to, *from; char *strncpy(to, from, count) char *to, *from; int count; strlen(s) char *s; char *index(s, c) char *s, c; char *rindex(s, c) char *s, c; DESCRIPTION
These functions operate on null-terminated strings. They do not check for overflow of any receiving string. Strcat appends a copy of string append to the end of string s. Strncat copies at most count characters. Both return a pointer to the null- terminated result. Strcmp compares its arguments and returns an integer greater than, equal to, or less than 0, according as s1 is lexicographically greater than, equal to, or less than s2. Strncmp makes the same comparison but looks at at most count characters. Strcasecmp and strncasecmp are identical in function, but are case insensitive. The returned lexicographic difference reflects a conversion to lower-case. Strcpy copies string from to to, stopping after the null character has been moved. Strncpy copies exactly count characters, appending nulls if from is less than count characters in length; the target may not be null-terminated if the length of from is count or more. Both return to. Strlen returns the number of non-null characters in s. Index (rindex) returns a pointer to the first (last) occurrence of character c in string s or zero if c does not occur in the string. Set- ting c to NULL works. 4th Berkeley Distribution October 22, 1987 STRING(3)
All times are GMT -4. The time now is 03:23 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy