From owner-freebsd-questions Fri Dec 17 14:11:13 1999 Delivered-To: freebsd-questions@freebsd.org Received: from athserv.otenet.gr (athserv.otenet.gr [195.170.0.1]) by hub.freebsd.org (Postfix) with ESMTP id 7F1E314CC2 for ; Fri, 17 Dec 1999 14:11:06 -0800 (PST) (envelope-from keramida@diogenis.ceid.upatras.gr) Received: from localhost.hell.gr (patr530-a039.otenet.gr [195.167.115.39]) by athserv.otenet.gr (8.9.3/8.9.3) with SMTP id AAA22340 for ; Sat, 18 Dec 1999 00:11:12 +0200 (EET) Received: (qmail 2013 invoked by uid 1001); 17 Dec 1999 15:34:52 -0000 Date: Fri, 17 Dec 1999 17:34:52 +0200 From: Giorgos Keramidas To: Dan Larsson Cc: freebsd-questions@freebsd.org Subject: Re: howto tokenize string in sh Message-ID: <19991217173452.D363@hades.hell.gr> Reply-To: keramida@ceid.upatras.gr References: <01BF4873.C18DD540.dl@tyfon.net> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Mailer: Mutt 1.0pre3i In-Reply-To: <01BF4873.C18DD540.dl@tyfon.net> Sender: owner-freebsd-questions@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG On Fri, Dec 17, 1999 at 09:47:38AM +0100, Dan Larsson wrote: | Having a string containing a path, what I need to do with it is to | determine if it is relative to current or not. | For this I imagine that splitting the path with the slashes as delimiters | to examine the tokens in between for a token containing two dots (..) is | one way of doing it. sed(1) is your friend. use something like: VARIABLE="`echo $DIRNAME | sed -e 's@/@ @g'`" then you can always use set $VARIABLE and use $1, $2 and so on for the parts of it, or something like: for component in $VARIABLE ;do echo $component done -- Giorgos Keramidas, "What we have to learn to do, we learn by doing." [Aristotle] To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-questions" in the body of the message