Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Remove items from lines 1

Status
Not open for further replies.

blarneyme

MIS
Jun 22, 2009
160
US
Code:
/my/filesystem host1(sync,ro,fsid=1) host2.domain.com(sync,ro,fsid=1) 127.0.0.10(sync,ro,fsid=1)
/other 192.168.1.1(sync,rw,fsid=2) host1(sync,rw,fsid=2) hosta(sync,rw,fsid=2)
/junk 192.168.1.2(sync,ro,fsid=3) hostc.domain.com(sync,rw,fsid=3)

I have a list containing hosts and IP's of servers that no longer ping, however, they still exist in the exports file. What I want is to remove hosts that no longer are running.

For example, if host2.domain.com and host1 no longer exist, then given the above:
Code:
/my/filesystem 127.0.0.10(sync,ro,fsid=1)
/other 192.168.1.1(sync,rw,fsid=2) hosta(sync,rw,fsid=2)
/junk 192.168.1.2(sync,ro,fsid=3) hostc.domain.com(sync,rw,fsid=3)
 
Hi

Code:
awk -vrm='host2.domain.com host1' 'BEGIN{n=split(rm,h)}{for(i=2;i<=NF;i++)for(j=1;j<=n;j++)if($i~"^"h[j]"\\("){for(e=i;e<NF;e++)$e=$(e+1);NF--;i--}}1' /input/file
Tested with [tt]gawk[/tt] and [tt]mawk[/tt].

Feherke.
 
I have a list containing hosts and IP's of servers
Any chance you could post an example ?

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top