I have a program written in awk and I want to extend it to do another task.
My program is a list of CVS log reports of a repository. For each file, I have some fields. One of the fields is the comment field. I want to know how I can check if a comment (which is a free text field) contains a number and if it does, I want to check if that number exists in another list of numbers (taken as input from another file).
For example,
If the list of numbers is
And I have the following log data
After the word "description", there can be 0, 1 or more commit data. In each commit data, I want to get the number from it, which can be anywhere in the 3rd or 4th line after the field separator "----------". And I want to compare that number with the list above and if it turns to be true, take some actions.
Can anyone help me how to do this. If needed, I can also send the already existing awk code I have.
I want to actually increment a counter everytime I get a match. The final count value is what I need. So every time I see a number in the commit message, I will compare with the list. If the number is present, count++ and then finally output count.
The data that I showed in the previous post is the output format I have. I need another column to this called "number of bugfixes". To get that number, I have a count.
I also have a list of bugs (but it is not classified at file level). I will use this list for comparison.
To find the number of bugs per file, I increment the count every time I see that a number in the commit message is also present in the list of
pseudo code would be
1) for each file,
do
*initialize count to 0
*for each commit message,
-find if commit message has a number in it.
-If it does, compare number with the numbers in list.
-If there is a match, increment count.
* Assign numberOfFixes=count;
done
In the code I already have, I am finding the other data I showed for each file in this way. and I want to do this task also in similar way.
Hi,
I want to compare strings length to a number but i am getting error. I want first name should be length of 8.
Please help.
#bin !/bin/bash
clear
echo -n "Enter name "
read name
IFS=_
ary=($name)
for key in "${!ary}"; do echo "$key${ary}"; done
##First name should be equal to 8... (8 Replies)
Hi All,
I have a file test.txt.
Content of test.txt :
1 vinay se
2 kumar sse
4 kishore tl
I am extracting the content of file with below command.
awk '$2 ~ "vinay" {print $0}' test.txt
Now instead of hardcoding $2 is there any way pass $2 as variable and compare with a... (7 Replies)
Hi all,
I was doing some string manipulation in my script and wanted to try using awk. However, I have been stuck with string compare. A simplified form of my conundrum is given below:
The below prints expected result (prints "Completed because that is the second element"):
$ echo... (5 Replies)
Need help for awk..
file will have comma separated numbers, I need check digits before 10 numbers eg ( 001)1234567890
Basically want to check country code of a mobile number.
eg:
abc,def,data, data,0011234567890, data,data
Script should be checking country code with 001, I will pass... (10 Replies)
I have the following simplified code that I am planning on putting into a larger shell script. I have been butchering it to try and make work amongst google searches and reading awk documentation.
amixer sset Master toggle | awk '{ if ( /^ Front Left/ { print $7 } == // ) print "MUTED" }'I... (2 Replies)
$ awk 'BEGIN{ pat111=0x1000000002E3E02; snBegin=0x1000000002E3E01; if (pat111<=snBegin) printf "a\n"}'
a
Result is not correct.
Looks like the number is too big.
Any idea?
Thx!
Please use code tags <- click the link! (2 Replies)
Hi to everyone,
Please some help over here.
Hi have array a with 6 elements and array b with 3 elements as shown inside BEGIN{} statement.
I need help to get the correct sintax (the part in red) to compare if string from array b is in array a and print the number
related for each match.... (3 Replies)
Hi,
I'm trying to compare the value in a field to the value in a variable using awk. This works:
awk '$7 == "101"'but this is what I want (and it doesn't work):
value=101
awk '$7 == "$value"'
Any help or insight on this would be great. Thanks in advance. (1 Reply)
Hi ,
I am new to shell scripting.
below is my requirement :
1) while running my .sh i will pass a string
2) i have to extract a folder name under a /config folder
3) i need to compare a input string in the folder name list
4) if that is true i have to continue my job else i have to... (2 Replies)