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 line having same number of "~"s. so i need to check each line is having same "~" or not . my script gives me output like
**output**
my script
----Actually Outpur Required
then should give an error msg like ~ count is not same as prevoius line.
Thanks & Regards
Ganesh
Moderator's Comments:
Please use code tags for scripts and other listings.
Last edited by pludi; 09-28-2010 at 07:07 PM..
Reason: added some additional things for better understanding
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)
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)
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)
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)
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)
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)
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)
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)
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)
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)