Sponsored Content
Top Forums Shell Programming and Scripting Check numeric fields greater than zero, and delete lines if appropriate Post 302370344 by Yorkie99 on Wednesday 11th of November 2009 07:08:26 AM
Old 11-11-2009
Thanks Franklin and radoulov

Both solutions work... but with a proviso... the log file contains similar lines but with the other types of errors seen on Cisco interfaces as well... and all these lines are deleted also. I just want to delete the lines I mentioned...

I'm guessing both solutions use a sort of 'delete everything else'. I just want 'delete line n and line n-1'

---------- Post updated at 07:08 AM ---------- Previous update was at 06:28 AM ----------

Since there's a start and end pattern to the section I want this to work on... I was thinking I might be able to nest awk's...

ie

Code:
awk '/start pattern/,/end pattern/ { awk '/input errors/ && ($2 + $5 + $9) > 0 {print s; print}{s=$0} }' infile

doesn't work though... I'm getting this error

Code:
bash: syntax error near unexpected token `{print'

Whats the correct syntax for this?
 

10 More Discussions You Might Find Interesting

1. Programming

check the given string is numeric or not.

Hi, how to check the given string is numeric or not , without converting ( using strtol...). for ex: if string is C01 - non-numeric data if string is 001 - numeric data TIA (11 Replies)
Discussion started by: knowledge_gain
11 Replies

2. Shell Programming and Scripting

Select lines in which column have value greater than some percent of total file lines

i have a file in following format 1 32 3 4 6 4 4 45 1 45 4 61 54 66 4 5 65 51 56 65 1 12 32 85 now here the total number of lines are 8(they vary each time) Now i want to select only those lines in which the values... (6 Replies)
Discussion started by: vaibhavkorde
6 Replies

3. Shell Programming and Scripting

How to check for a Numeric Value?

Using shell, I have a variable, how can I check that variable for a numeric value such as "41.0"? My program needs to do one things if the numeric value is found, and another if something else such as a string of letter is found. is there a specific character that denotes a numeral? The... (2 Replies)
Discussion started by: chagan02
2 Replies

4. Shell Programming and Scripting

Delete words greater than a specific length

HI All, I have a file with contents like this: apple computer terminal applecomputernetworkrouterterminalrouter network router applecomputernetworkrouterterminalrouter I want to remove all lines with length greater than "18 alphabets". Hence, my output should be: apple computer... (1 Reply)
Discussion started by: shoaibjameel123
1 Replies

5. Shell Programming and Scripting

search column and delete row if greater than value

Hi, as the title states i need to find a way to search a column for values great than 1000, and if it is, then delete that row. An example 1 7.021 6.967 116.019 4 U 6.980E+07 0.000E+00 e 0 0 0 0 2 8.292 7.908 118.063 3 U 1.440E+07 0.000E+00 e 0 821 814 ... (3 Replies)
Discussion started by: olifu02
3 Replies

6. UNIX for Dummies Questions & Answers

check if a decimal number is greater than zero

Hello, In my code I am checking to see if a variable that contains a decimal number is greater than 0 in the following manner: if do something fi However I am getting the error message (if $i for the current iteration holds 9.6352) command 9.6352 is not found How can I rectify... (5 Replies)
Discussion started by: Gussifinknottle
5 Replies

7. Shell Programming and Scripting

To perform sum aggregation on numeric fields

Hi all, I have following scenario to perform sum aggregation on certain columns Node Allocated_Space Pool_Name CS_Group Utilized Space -------- ---------------- ---------- --------- -------------- bdw1a_lun01 300 bdw_p0 ... (2 Replies)
Discussion started by: ckwan
2 Replies

8. Shell Programming and Scripting

Need to check the value greater than or less than and give out put to a file

HI, I have one file which is as below cat /var/tmp/test1 | awk '{ print $3}'|grep -v affected Data ---------- 200.4 . The above 200 value is changable by the database script. Now I need a script that checks the value 200.4 and the script shoud give out put if value is more than 225 (2 Replies)
Discussion started by: phani4u
2 Replies

9. How to Post in the The UNIX and Linux Forums

Very Urgent ---Need to delete the log files when the disk used% greater than 85% using df -k*

Hi, I am new to Shell scripts. I have an urgent requirement to find the disk space using "df -k". from that output,I need to check the used% whether greater than 85%. if it is greater than 85% then need to delete my log files. It is very urgent please some one help me. Thanks in Advance... (1 Reply)
Discussion started by: Anandbarnabas
1 Replies

10. Shell Programming and Scripting

Need to delete the log files when the disk used% greater than 85% using df -k

Hi, I am new to Shell scripts. I have an urgent requirement to find the disk space using "df -k". from that output,I need to check the used% whether greater than 85%. if it is greater than 85% then need to delete my log files. It is very urgent please some one help me. Thanks in Advance... (2 Replies)
Discussion started by: Anandbarnabas
2 Replies
NDP(8)							    BSD System Manager's Manual 						    NDP(8)

NAME
ndp -- control/diagnose IPv6 neighbor discovery protocol SYNOPSIS
ndp -a [-nt] ndp -A wait [-nt] ndp -c [-nt] ndp -d [-nt] hostname ndp -f [-nt] filename ndp -H ndp -I [delete | interface] ndp -i interface [flags...] ndp -p ndp -P ndp -r ndp -R ndp -s [-nt] nodename ether_addr [temp] [proxy] DESCRIPTION
The ndp command manipulates the address mapping table used by Neighbor Discovery Protocol (NDP). -a Dump the currently existing NDP entries. -A wait Repeat -a (dump NDP entries) every wait seconds. -c Erase all the NDP entries. -d Delete specified NDP entry. -f Parse the file specified by filename. -H Harmonize consistency between the routing table and the default router list; install the top entry of the list into the kernel rout- ing table. -I [delete | interface] Shows or specifies the default interface used as the default route when there is no default router. If no argument is given to the option, the current default interface will be shown. If an interface is specified, the interface will be used as the default. If a special keyword delete is specified, the current default interface will be deleted from the kernel. -i interface [flags...] View ND information for the specified interface. If additional arguments flags are given, ndp sets or clears the specified flags for the interface. Possible flags are as follows. All of the flags can begin with the special character '-', which means the flag should be cleared. nud turn on or off NUD (Neighbor Unreachability Detection) on the interface. NUD is usually turned on by default. -n Do not try to resolve numeric address to hostname. -p Show prefix list. -P Flush all the entries in the prefix list. -r Show default router list. -R Flush all the entries in the default router list. -s Register an NDP entry for a node. The entry will be permanent unless the word temp is given in the command. If the word proxy is given, this system will act as an proxy NDP server, responding to requests for hostname even though the host address is not its own. -t Print timestamp on each entries, to make it possible to merge output with tcpdump(1). Most useful when used with -A. RETURN VALUES
The ndp command will exit with 0 on success, and non-zero on errors. SEE ALSO
arp(8) HISTORY
The ndp command first appeared in WIDE Hydrangea IPv6 protocol stack kit. BSD
May 17, 1998 BSD
All times are GMT -4. The time now is 02:28 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy