Egrep -v command not filtering correctly


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Egrep -v command not filtering correctly
# 1  
Old 03-28-2019
Egrep -v command not filtering correctly

Hello guys,

I have an issue when trying to do an egrep -v on a file, let me show you.
I want to filter the last column as to where it filters out the columns with asterisks and zeros ( * and 0 ) it is working properly up to a certain point where I have a value of '10000' which is also getting filtered by the '0'.

This is the result:
e.g.
Code:
$ egrep -v "\*|0" grep.txt
Queue                                        Get  Put  CurDepth
-----------------------------------------------------------------
SYSTEM.DEAD.LETTER.QUEUE                     EN   EN   712
WDW_ORDERS_ONEVIEW_Q                         EN   EN   1

This is the original list:
Code:
Queue                                        Get  Put  CurDepth
-----------------------------------------------------------------
SYSTEM.CLUSTER.COMMAND.QUEUE                 EN   EN   0
SYSTEM.CLUSTER.TRANSMIT.QUEUE                EN   EN   0
SYSTEM.DEAD.LETTER.QUEUE                     EN   EN   712
WDW_LVLN_Q                                   EN   EN   0
WDW_LVLN_Q_A                                 EN   EN   **
WDW_LVLN_Q_B                                 EN   EN   **
WDW_LVLN_Q_DARK                              EN   EN   0
WDW_ORDERS_ONEVIEW1_Q                        EN   EN   0
WDW_ORDERS_ONEVIEW1_Q_A                      EN   EN   **
WDW_ORDERS_ONEVIEW1_Q_B                      EN   EN   **
WDW_ORDERS_ONEVIEW1_Q_DARK                   EN   EN   0
WDW_ORDERS_ONEVIEW_Q                         EN   EN   1
WDW_ORDERS_ONEVIEW_Q_A                       EN   EN   **
WDW_ORDERS_ONEVIEW_Q_B                       EN   EN   **
WDW_ORDERS_ONEVIEW_Q_DARK                    EN   EN   0
WDW_RM_FULFL_TO_TPV3_Q                       EN   EN   0
WDW_RM_FULFL_TO_TPV3_Q_A                     EN   EN   **
WDW_RM_FULFL_TO_TPV3_Q_B                     EN   EN   **
WDW_RM_FULFL_TO_TPV3_Q_DARK                  EN   EN   0
WDW_TRAVELPLAN_V31_Q                         EN   EN   0
WDW_TRAVELPLAN_V31_Q_A                       EN   EN   **
WDW_TRAVELPLAN_V31_Q_B                       EN   EN   **
WDW_TRAVELPLAN_V31_Q_DARK                    EN   EN   0
WDW_TRAVELPLAN_V3_Q                          EN   EN   10000
WDW_TRAVELPLAN_V3_Q_A                        EN   EN   **
WDW_TRAVELPLAN_V3_Q_B                        EN   EN   **
WDW_TRAVELPLAN_V3_Q_DARK                     EN   EN   0
WDW_XBMS_TRAVEL_PLAN_BUNDLE_Q                EN   EN   0
WDW_XBMS_TRAVEL_PLAN_BUNDLE_Q_A              EN   EN   **
WDW_XBMS_TRAVEL_PLAN_BUNDLE_Q_B              EN   EN   **
WDW_XBMS_TRAVEL_PLAN_BUNDLE_Q_DARK           EN   EN   0
WDW_XBMS_TRAVEL_PLAN_Q                       EN   EN   0
WDW_XBMS_TRAVEL_PLAN_Q_A                     EN   EN   **
WDW_XBMS_TRAVEL_PLAN_Q_B                     EN   EN   **
WDW_XBMS_TRAVEL_PLAN_Q_DARK                  EN   EN   0

if you are able to see there is another column with a '10000' in the last column which should also be filtered in the first egrep -v result and is not showing.

can someone please help, I have tried also a awk syntax but to no avail, it keeps showin only 2 results instead of 3.

any help would be greatly appreciated. thanks guys.
# 2  
Old 03-28-2019
Welcome to the forum.



How about:

Code:
grep -Ev "(\*| 0)$" file
Queue                                        Get  Put  CurDepth
-----------------------------------------------------------------
SYSTEM.DEAD.LETTER.QUEUE                     EN   EN   712
WDW_ORDERS_ONEVIEW_Q                         EN   EN   1
WDW_TRAVELPLAN_V3_Q                          EN   EN   10000

This User Gave Thanks to RudiC For This Post:
# 3  
Old 03-28-2019
grep does correctly, what you commanded to do.

the regex egrep -v "\*|0" grep.txt matches 10000.

Check the regex manual to improve your understanding of the topic(man 7 regex).

That would be more what you want:

Code:
grep -vE '([^0-9]0|\*)$' grep.txt

This User Gave Thanks to stomp For This Post:
# 4  
Old 03-28-2019
thanks for your answers guys , I will go ahead and read the regex man page to get more ideas and a better understanding. SmilieSmilie
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Egrep command is not working for me

my file is below REREGISTER is something to Failed to create the request Failed to create the request in not easy I know how REREGISTERcommand i run is egrep 'REREGISTER|Failed|to|create|the|request' test1 expected output REREGISTER is something to Failed to create the request i should... (2 Replies)
Discussion started by: mirwasim
2 Replies

2. Shell Programming and Scripting

help in egrep command in file

Hi Guys, I need hepl on egrep commnad I have one file and i need grep only specific lines.. EX: 2012-04-01 02:15:14 w 2012-04-01 02:15:14 w 2012-04-01 02:15:14 w 2012-10-26 02:15:14 w 2012-04-01 02:15:14 w 2012-10-26 02:15:14 w 2012-10-26 02:15:14 w 2012-10-26 03:18:56 M... (1 Reply)
Discussion started by: asavaliya
1 Replies

3. Shell Programming and Scripting

Help with egrep command

Hello folks, Here's how my current egrep command works: egrep "NY|DC|LA|VA|MD" state_data.txt I am planning to use a file to enter all allowable state values like say a new state_names.lookup with the following data: NY DC LA VA MD egrep "`cat state_names.lookup`"... (6 Replies)
Discussion started by: calredd
6 Replies

4. Shell Programming and Scripting

Help with egrep command

cat /tmp/inventory.csv|grep AARP|egrep -v "T11|12.4\(7\)" how do i exclude in addition to above 12.4\(3\) I have tried adding this in i.e -v "T11|12.4\(7\)|12.4\(3\)" but it did not work (3 Replies)
Discussion started by: slashbash
3 Replies

5. Shell Programming and Scripting

egrep command and order

Hi All, Here is my question. I have two files, file1.txt and file2.txt. I need the line number (index number) of file2.txt where the words in file1.txt appear. But they have to be in the same order as file1.txt. In example, file1.txt Z K A ... T file2.txt W A Q R (6 Replies)
Discussion started by: senayasma
6 Replies

6. Shell Programming and Scripting

CRON shell script only runs correctly on command line

Hi, I'm new to these forums, and I'm hoping that someone can solve this problem... To make things short: I have DD-wrt set up on a router. I'm trying to run a script in CRON that fetches the daily password from my database using SSH. CRON is set like so(in web interface): * * * *... (4 Replies)
Discussion started by: louieaw
4 Replies

7. UNIX for Dummies Questions & Answers

Date command to obtain the last month is not working correctly..

Hello, I could not find the exactly same post here.. so I will explain what I did to get the last month using date command. I used date +%Y-%m -d "-1 months" to get the last month. However, the returned value of above command on 2009/10/31 was 2009 10 and not 2009 09.. and the... (9 Replies)
Discussion started by: tigersk
9 Replies

8. Shell Programming and Scripting

Query regarding egrep command

Hi All, I am having a query regarding the usage of egrep command. i am having two unix environmanets in environment when i am using "egrep -f" it is working fine and other unix environment i am getting a syntax error. Please let me know if i need to set any environmane variables. ... (12 Replies)
Discussion started by: Sriram.Vedula53
12 Replies

9. Shell Programming and Scripting

Help with egrep command

Hi All, I am using egrep command to search one pattern. Following is the command i am using egrep -i "ACL*" filename but its also giving me the records which do not contain ACL. any help would be appreciated. Regards, Sam (3 Replies)
Discussion started by: sam25
3 Replies

10. Shell Programming and Scripting

egrep command

I'd like to grep a pattern of a version number as *_number.number.number number should be digit my grep is |egrep '^*++\.+' It works for V_3.2.1 or V _5.3.2 but not with V_43.6.543 !!!!! How can I specify any repetition of digit in the ? thanks, (4 Replies)
Discussion started by: annelisa
4 Replies
Login or Register to Ask a Question