From mboxrd@z Thu Jan 1 00:00:00 1970 MIME-Version: 1.0 In-Reply-To: References: <4AB1FB95.4070005@maht0x0r.net> Date: Thu, 17 Sep 2009 14:35:27 +0200 Message-ID: From: yy To: Fans of the OS Plan 9 from Bell Labs <9fans@9fans.net> Content-Type: text/plain; charset=ISO-8859-1 Subject: Re: [9fans] awk help; not plan9 matter Topicbox-Message-UUID: 6ff132c0-ead5-11e9-9d60-3106f5b1d025 if you want to preserve white-space, you better forget about fields and work with indexes on the string, match is your friend: % echo '1 3 4 8' | awk '{match($0, /[ \t]*[^ \t]+[ \t]+/);a=RLENGTH+1;match(substr($0, a), /[ \t]/);print substr($0,0,a-1) "hell" substr($0,RSTART+a)}' 1 hell 4 8 this is indeed a bit OT here, maybe next time you prefer trying in #awk at freenode, where this kind of problems are welcomed -- - yiyus || JGL . 4l77.com