Mombu the Programming Forum

Go Back   Mombu the Programming Forum > Programming > how to deal with spaces and tabs
User Name
Password
REGISTER NOW! Mark Forums Read




Reply Bookmark and Share
1 30th June 20:55
m.h
External User
 
Posts: 1
Default how to deal with spaces and tabs



Hi,

I have an /etc/hosts where I want to change IP addresses but my problem
is that the separator can be multiple spaces or multipe tabs.

=====etc/hosts===
10.244.200.1 sapas2 SAPAS2
10.244.201.17 prevcs PREVCS
10.244.200.6 sapas3 SAPAS3
10.244.200.9 sapas4 SAPAS4
10.244.201.11 sapas1 SAPAS1 sapmsgsrv
10.244.201.12 prodvcs PRODVCS
10.244.201.33 sapps0 SAPPS0
10.244.201.15 oraaq1 ORAAQ1
#10.244.201.18 sapaq1 SAPAQ1
#10.244.201.26 saptc1 SAPTC1
#10.244.201.29 sapdv1 SAPDV1
10.246.17.114 sapaq1 SAPAQ1
10.246.9.112 saptc1 SAPTC1
10.246.17.110 sapdv1 SAPDV1
=====

example:
How to change the 10.244.200.1 ip address Only knowing that separator
would be spaces or tabs.

sed 's/10\.244\.200\.1 /192\.168\.10\.1 /' works only if there is a
space after the address!!

Any help would be appreciated.

thanks

haed.
  Reply With Quote


 


2 30th June 20:56
gazelle
External User
 
Posts: 1
Default how to deal with spaces and tabs



sed is off-topic (and useless)

I think what you want is:

BEGIN { OFS="\t" }
sub(/10\.244\.200\.1/,"192.168.10.1",$1)+1
  Reply With Quote


 


Reply


Thread Tools
Display Modes


Some other forums that might be of your interest : Development, Ada, Apple script, Assembler, Awk, Beos, Basic, C, C++, C#, C# .net, .net, .net frameworks, Asp .net, Clarion, Clipper, Clos, Clu, Cobol, Coldfusion, Delphi, Dylan, Eiffel, Forth, Fortran, Haskell, Hermes, Icon, Idl, Java, Java script, Jscript .net, Jcl, Linoleum, Lisp, Lotus, Limbo, Logo, Ml, Mumps, Oberon, Postscript, Pop, Pl1, Prolog, Python, Ruby, Pascal, Perl, Php, Rebol, Rexx, Sed, Sather, Scheme, Smalltalk, Tcl, Vhdl, Vrml, Visual basic, Visual basic .net, Yorick, Mysql, Omnis, Postgresql, Xbase, Access, Oracle, Adabas, Berkeley, Btrieve, Filemaker, Gupta, Db2, Informix, Ingres, Mssql server, Object, Olap, Paradox, Rdb, Revelation, Sybase, Theory, Dbase, Html, Java script, Css, Flash, Photoshop, Corel script, Xml, Tech, Beos, Gem, Hp48, Hpux, Linux, Mac, Ms-dos, Os2, Palm, Solaris, Ti99, Windows, Xenix, Aos, Chorus, Geos, Inferno, Lantastic, Lynx, Mach, Minix, Netware, Os9, Parix, Plan9, Psos, Qnx, Xinu, Sco, Unix, Aix, Aux, 386bsd, Bsdi, Freebsd, Netbsd, Openbsd, Ultrix, Amd, Intel, Aptiva, Buz, Deals, Homebuilt, Overclocking, Programming, Extra forums


Copyright © 2006 SmartyDevil.com - Dies Mies Jeschet Boenedoesef Douvema Enitemaus -
666