Results 1 to 3 of 3
Hi,
1) I need to search a field value to check for exact 0. If the number is 0, it should throw error.
The line to be searched looks like ...
- 08-06-2010 #1Just Joined!
- Join Date
- Jul 2010
- Posts
- 16
grep for exact number 0
Hi,
1) I need to search a field value to check for exact 0. If the number is 0, it should throw error.
The line to be searched looks like as below.
"Output Rows [1], Affected Rows [1], Applied Rows [1], Rejected Rows [0]"
Here I have to search whether the affected rows is 0. But the code below picks up other values also (lie 10, 20.. etc). How do we write to get an exact match for 0?
2) Also, I need to check whether the rejected rows > 0Code:affected=`echo ${line} | cut -f6 -d" " ` affectedcount='echo ${affected} |grep 0 `
Code:rejected=`echo ${line} | cut -f12 -d" " ` rejectedcount='echo {rejected} |grep [1-9]`
3)Can we combine these two statements in a better way to get the desired results?
Thanks
Maya
- 08-07-2010 #2
You can use grep to extract only the numeric characters :
--- rod.Code:affectedcount=$(echo ${line} | cut -f6 -d" " | grep -o '[0-9]\+')Stuff happens. Then stays happened.
- 08-10-2010 #3Just Joined!
- Join Date
- Jul 2010
- Posts
- 53
awk -F, '$2==0{print;}'


Reply With Quote