Sponsored Content
Top Forums Shell Programming and Scripting sed/awk : how to delete lines based on IP pattern ? Post 302565294 by albator1932 on Tuesday 18th of October 2011 04:46:18 AM
Old 10-18-2011
Thanks to you two

I will try this tomorrow and I'll let you know if I've succeded doing what I want Smilie

---------- Post updated 18-10-11 at 10:46 AM ---------- Previous update was 17-10-11 at 06:56 PM ----------

Hello again

Here is what I've done :

Code:
for HOST in $(cat stations.lst | uniq)
do
  # echo -n "$HOST"
  if ping -c 1 $HOST > /dev/null 2>&1
  then
    HOSTNAME_val=`rsh  $HOST "cp /etc/hosts /etc/hosts.dirty ; sed '/152\.15\./d;/152\.9\./d;/152\.19\./d;/44\.33\./d' /etc/hosts > /etc/hosts.clean ; mv /etc/hosts.clean /etc/hosts"`
    val1=`echo $HOSTNAME_val` 
    echo $val1
  else 
    echo "$HOST ; not responding"
  fi
done

The reason why I did not use the -i option is because many of the workstations are HP-UX and sed does not recognize de -i option on this system...

It's working great, thanks !
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

SED: match pattern & delete matched lines

Hi all, I have the following data in a file x.csv: > ,this is some text here > ,,,,,,,,,,,,,,,,2006/11/16,0.23 > ,,,,,,,,,,,,,,,,2006/12/16,0.88 < ,,,,,,,,,,,,,,,,this shouldnt be deleted I need to use SED to match anything with a > in the line and delete that line, can someone help... (7 Replies)
Discussion started by: not4google
7 Replies

2. Shell Programming and Scripting

sed delete pattern skipping first n lines of file.

I have files of more than 10K lines that I need to delete lines that contain a pattern, but I want to keep the first few lines intact. Can this be done with sed? (7 Replies)
Discussion started by: tkg
7 Replies

3. Shell Programming and Scripting

copy, then delete lines in file with sed using a pattern

I need to copy lines to a new file from files with sed using a pattern in char postions 1-3. Then after the copy, I need to delete those same lines from the input files. For example, string "ABC" in pos 1-3 (6 Replies)
Discussion started by: laksjfhoius9123
6 Replies

4. Shell Programming and Scripting

Sed or awk : pattern selection based on special characters

Hello All, I am here again scratching my head on pattern selection with special characters. I have a large file having around 200 entries and i have to select a single line based on a pattern. I am able to do that: Code: cat mytest.txt | awk -F: '/myregex/ { print $2}' ... (6 Replies)
Discussion started by: usha rao
6 Replies

5. Shell Programming and Scripting

sed pattern to delete lines containing a pattern, except the first occurance

Hello sed gurus. I am using ksh on Sun and have a file created by concatenating several other files. All files contain header rows. I just need to keep the first occurrence and remove all other header rows. header for file 1111 2222 3333 header for file 1111 2222 3333 header for file... (8 Replies)
Discussion started by: gary_w
8 Replies

6. UNIX for Dummies Questions & Answers

[Solved] deleting pattern based lines in sed

HI, My input file contains below data: DFHDR 12345110 1,200 2,-100 1,100 2,123 12345110 1,300 2,200 DFTLR In the above data, the first line and last lines should be remove as well as the lines in which contains 110 as position(6,7,8 position) should also be removed, How we... (0 Replies)
Discussion started by: pandeesh
0 Replies

7. Shell Programming and Scripting

Sed/awk to delete single lines that aren't touching other lines

Hello, I'm trying to figure out how to use sed or awk to delete single lines in a file. By single, I mean lines that are not touching any other lines (just one line with white space above and below). Example: one two three four five six seven eight I want it to look like: (6 Replies)
Discussion started by: slimjbe
6 Replies

8. Shell Programming and Scripting

Sed delete blank lines upto first pattern match

Hi Im trying to do the following in sed. I want to delete any blank line at the start of a file until it matches a pattern and then stops. for example: Input output: I have got it to work within a range of two patterns with the following: sed '/1/,/pattern/{/^]*$/d}' The... (2 Replies)
Discussion started by: duonut
2 Replies

9. Shell Programming and Scripting

sed search pattern and delete lines

Hello, i have a question. My problem is that i have a file like: TEST JOHN ADAM MICHAEL SEBASTIAN ANDY i want find for MICHAEL and want delete lines like this: TEST (4 Replies)
Discussion started by: eightball
4 Replies

10. Shell Programming and Scripting

Delete lines based on pattern match

BASH in Solaris 10 I have a log file like below. Whenever the pattern ORA-39083 is encountered, I want to delete the line which has this pattern and 3 lines below it. $ cat someLogfile.txt ORA-39083: Object type OBJECT_GRANT failed to create with error: ORA-01917: user or role 'CMPA' does... (4 Replies)
Discussion started by: kraljic
4 Replies
SHOREWALL6-ROUTESTO(5)						  [FIXME: manual]					    SHOREWALL6-ROUTESTO(5)

NAME
routestopped - The Shorewall6 file that governs what traffic flows through the firewall while it is in 'stopped' state. SYNOPSIS
/etc/shorewall6/routestopped DESCRIPTION
This file is used to define the hosts that are accessible when the firewall is stopped or is being stopped. When shorewall6-shell is being used, the file also determines those hosts that are accessible when the firewall is in the process of being [re]started. The columns in the file are as follows (where the column name is followed by a different name in parentheses, the different name is used in the alternate specification syntax). INTERFACE - interface Interface through which host(s) communicate with the firewall HOST(S) - [-|address[,address]...] Optional comma-separated list of IP/subnet addresses. If your kernel and ip6tables include iprange match support, IP address ranges are also allowed. If left empty or supplied as "-", 0.0.0.0/0 is assumed. OPTIONS - [-|option[,option]...] An optional comma-separated list of options. The order of the options is not important but the list can contain no embedded whitespace. The currently-supported options are: routeback Set up a rule to ACCEPT traffic from these hosts back to themselves. Beginning with Shorewall 4.4.9, this option is automatically set if routeback is specified in shorewall6-interfaces[1] (5) or if the rules compiler detects that the interface is a bridge. source Allow traffic from these hosts to ANY destination. Without this option or the dest option, only traffic from this host to other listed hosts (and the firewall) is allowed. If source is specified then routeback is redundant. dest Allow traffic to these hosts from ANY source. Without this option or the source option, only traffic from this host to other listed hosts (and the firewall) is allowed. If dest is specified then routeback is redundant. critical Allow traffic between the firewall and these hosts throughout '[re]start', 'stop' and 'clear'. Specifying critical on one or more entries will cause your firewall to be "totally open" for a brief window during each of those operations. Examples of where you might want to use this are: o 'Ping' nodes with heartbeat. o LDAP server(s) if you use LDAP Authentication o NFS Server if you have an NFS-mounted root filesystem. Note The source and dest options work best when used in conjunction with ADMINISABSENTMINDED=Yes in shorewall6.conf[2](5). EXAMPLE
Example 1: #INTERFACE HOST(S) OPTIONS eth2 2002:ce7c:92b4::/64 eth0 2002:ce7c:92b4:1::/64 br0 - routeback eth3 - source FILES
/etc/shorewall6/routestopped SEE ALSO
http://shorewall.net/starting_and_stopping_shorewall.htm http://shorewall.net/configuration_file_basics.htm#Pairs shorewall6(8), shorewall6-accounting(5), shorewall6-actions(5), shorewall6-blacklist(5), shorewall6-hosts(5), shorewall6-interfaces(5), shorewall6-maclist(5), shoewall6-netmap(5),shorewall6-params(5), shorewall6-policy(5), shorewall6-providers(5), shorewall6-rtrules(5), shorewall6-rules(5), shorewall6.conf(5), shorewall6-secmarks(5), shorewall6-tcclasses(5), shorewall6-tcdevices(5), shorewall6-tcrules(5), shorewall6-tos(5), shorewall6-tunnels(5), shorewall6-zones(5) NOTES
1. shorewall6-interfaces http://www.shorewall.net/manpages6/shorewall6-interfaces.html 2. shorewall6.conf http://www.shorewall.net/manpages6/shorewall6.conf.html [FIXME: source] 06/28/2012 SHOREWALL6-ROUTESTO(5)
All times are GMT -4. The time now is 12:57 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy