Sponsored Content
Top Forums Shell Programming and Scripting Script that takes IP address as an Input and deletes 7 lines Post 302899085 by MadeInGermany on Saturday 26th of April 2014 03:34:57 AM
Old 04-26-2014
Yoda's code optimized
Code:
awk '
(NR == FNR) {
 A[$1]
 next
}
($1 in A) {
 c = 8
}
!(c && c--)
' ipfile infile

---------- Post updated at 02:34 AM ---------- Previous update was at 01:39 AM ----------

If output on terminal looks good you can overwrite the input as follows
Code:
infile=./infile
cp -p $infile $infile.old &&
awk '
(NR == FNR) {
 A[$1]
 next
}
($1 in A) {
 c = 8
}
!(c && c--)
' ipfile $infile.old > $infile


Last edited by MadeInGermany; 04-26-2014 at 03:45 AM.. Reason: delete not print
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Shell Program which deletes all lines ...

Shell Program which deletes all lines containing the word "UNIX" in the files supplied as argument..please help me to do this task :) (4 Replies)
Discussion started by: abhiseknitd
4 Replies

2. Programming

My exe takes more time for specied input

My application is coded in C++ and uses pro C to get data from oracle database. My executable file is taking more time to execute for some specified input. Is there any way to check where it spends the maximum time? (1 Reply)
Discussion started by: SamRoj
1 Replies

3. Shell Programming and Scripting

how to display an error if input value is not an IP address??

Dears, I need your assistance, I'm creating a shell script to read the IP address of a server and i would like to display an error message in red if the entered value is not an IP. any ideas how can i do it?:confused: #!/bin/sh echo "Please enter the server IP address: \c" read IPadd... (3 Replies)
Discussion started by: Dendany83
3 Replies

4. Shell Programming and Scripting

awk script - reading input lines

Can I do something like, if($0==/^int.*$/) { print "Declaration" } for an input like: int a=5; If the syntax is right, it is not working for me, but I am not sure about the syntax. Please help. Thanks, Prasanna (1 Reply)
Discussion started by: prasanna1157
1 Replies

5. Shell Programming and Scripting

A script that deletes files.

I want to write a script that deletes files inside the dir. However, the script should also allow the user to confirm by pressing (d) key before deleting files.. #!/bin/bash for file in $1/* do size='ls -l $file | cut -f 5 -d " "' name='ls -l $file | cut -f 9 -d " "' ... (1 Reply)
Discussion started by: herberwz
1 Replies

6. Shell Programming and Scripting

Script that takes strings as input

Hello all! I need to take a series of inputs passed to one shell script and pass them to a second shell script. For example, the first shell script, script_one.sh, has the following inputs: ./script_one -u username -p password -option1 string1 -option2 -string2 ....Inside of script_one.sh... (4 Replies)
Discussion started by: bashnewbee
4 Replies

7. Shell Programming and Scripting

Need help to run sql query from a script..which takes input from a file

I need to run sql script from shell script which takes the input from a file and contents of file will be like : 12345 34567 78657 and query will be like : select seq_nbr from bus_event where event_nbr='12345'; select seq_nbr from bus_event where event_nbr='34567'; select seq_nbr... (1 Reply)
Discussion started by: rkrish
1 Replies

8. Shell Programming and Scripting

Help in unix script to join similar lines of input

Hi, I have been thinking of how to script this but i have no clue at all.. Could someone please help me out or give me some idea on this? I would like to group those lines with the same first variable in each line, joining the 2nd variables with commas. Let's say i have the following input. ... (3 Replies)
Discussion started by: rei125
3 Replies

9. UNIX for Dummies Questions & Answers

sed command that deletes lines with 3-5 digit strings

Hello! My final exam in my Linux class is tomorrow, and I was just reviewing the grep and sed commands. I came across an example, by which I got stumped: it asks to provide a sed command that deletes all lines that contain exactly 3 to 5 digit strings, from a file. In this case, I created a... (3 Replies)
Discussion started by: kalpcalp
3 Replies

10. UNIX for Beginners Questions & Answers

Remove Comment Lines From Script/Input File

Hello, I have a SAS code that predominantly has comments line and the real code like below and i want to remove ONLY THE COMMENTS from the code in the single line or spanned across multiple lines. /******************************************************************** *** This Is a Comment... (4 Replies)
Discussion started by: arooonatr
4 Replies
ATMADDR(8)						       Maintenance Commands							ATMADDR(8)

NAME
atmaddr - list and maintain local ATM addresses SYNOPSIS
atmaddr [-n] [itf] atmaddr -r [itf] atmaddr -a [itf] atm_addr atmaddr -d [itf] atm_addr atmaddr -V DESCRIPTION
atmaddr is used to list the local addresses configured for ATM interfaces and to manually change the list of addresses. If the interface number itf is omitted, interface 0 is used by default. The ATM address atm_addr can be any valid ATM SVC address, e.g. an E.164 address or an ATM Forum NSAP address. If invoked without options, atmaddr lists the addresses that are currently configured on the specified interface. Note that local ATM addresses are normally automatically maintained by the ILMI demon. OPTIONS
-a append the specified address at the end of the list. -d delete the specified address from the list. -n numeric address output only. No address to name translation is attempted. -r reset (clear) the local address list of the specified interface. -V print the version number of atmaddr on standard output and exit. AUTHOR
Werner Almesberger, EPFL ICA <Werner.Almesberger@epfl.ch> SEE ALSO
ilmid(8) Linux April 26, 2000 ATMADDR(8)
All times are GMT -4. The time now is 02:55 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy