From owner-freebsd-questions@FreeBSD.ORG Thu Jan 29 07:42:40 2004 Return-Path: Delivered-To: freebsd-questions@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 7AD5816A4CE for ; Thu, 29 Jan 2004 07:42:40 -0800 (PST) Received: from dan.emsphone.com (dan.emsphone.com [199.67.51.101]) by mx1.FreeBSD.org (Postfix) with ESMTP id 7DC6043D58 for ; Thu, 29 Jan 2004 07:42:33 -0800 (PST) (envelope-from dan@dan.emsphone.com) Received: (from dan@localhost) by dan.emsphone.com (8.12.10/8.12.10) id i0TFgW8h026062; Thu, 29 Jan 2004 09:42:32 -0600 (CST) (envelope-from dan) Date: Thu, 29 Jan 2004 09:42:32 -0600 From: Dan Nelson To: zhangweiwu@realss.com Message-ID: <20040129154232.GB31560@dan.emsphone.com> References: Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-OS: FreeBSD 5.2-CURRENT X-message-flag: Outlook Error User-Agent: Mutt/1.5.5.1i cc: questions@freebsd.org Subject: Re: use \000 in sed X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 29 Jan 2004 15:42:40 -0000 In the last episode (Jan 29), Zhang Weiwu said: > Hello. I wish to see all the files in some pathes in a string. > > Say, I wish to list all files in $PATH and manpath(1) > > What I can think of is to use > #manpath | sed "s/:/ /g" |xargs ls > (This is useful when auto-completing man command in a shell, say, csh). > > This works, but the command is wrong when a path contain a space in it. > > I think a better way is to replace ":" with \000, the "NULL". In this way I > can use "xargs -0" to pass all pathes to ls(1) > #manpath | sed s/:/\000/g" |xargs -0 ls I'm not sure that sed can process \123-style octal characters, since it already uses the \ character for backreferences. Since you're only replacing one letter, you can use tr: manpath | tr ':' '\000' | xargs -0 ls -- Dan Nelson dnelson@allantgroup.com