From owner-freebsd-questions@FreeBSD.ORG Fri Jul 2 16:06:06 2010 Return-Path: Delivered-To: questions@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id DEF4A106567E for ; Fri, 2 Jul 2010 16:06:06 +0000 (UTC) (envelope-from swell.k@gmail.com) Received: from mail-vw0-f54.google.com (mail-vw0-f54.google.com [209.85.212.54]) by mx1.freebsd.org (Postfix) with ESMTP id 8B5098FC0A for ; Fri, 2 Jul 2010 16:06:06 +0000 (UTC) Received: by vws6 with SMTP id 6so3415108vws.13 for ; Fri, 02 Jul 2010 09:06:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:from:to:cc:subject:references :date:in-reply-to:message-id:user-agent:mime-version:content-type; bh=2Flqt2BXOyc+wZfsQr665x7hHb78sXrnpyY1bSiFd9o=; b=g/JV3Dmn+rsgVnbnQskERC+uJFko+DQguOuyr7Qi3VcoObkSg40ayUYGmTvAokzlyc d2SsyFQrbQMgXgCJ0MdmnP5OoW/dMfaW/JLU/LNrq/j0GLwSKwbmAWyxoPnG2RmWrRhs IPZzjYxEQ3MrezbrEtI4UOBeBmDPKnZiDjHzI= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=from:to:cc:subject:references:date:in-reply-to:message-id :user-agent:mime-version:content-type; b=JCfATCqxFZ97dDR0hzzrvdMlUg818pwSo9pJaHhbTVaUwxP3zAB4N7+yRgSZryn7QY 0eO1Y0vfrT1LILR53ADhso3T25B5HdR6GngfdUtUPj0YsEK2sMq5/kZT6EDEJlEwJ+u/ q7Q/fHu3FjQ8Iwb8C4WusC0ixtQ4Sj3NIe5wU= Received: by 10.220.128.203 with SMTP id l11mr451406vcs.265.1278084912047; Fri, 02 Jul 2010 08:35:12 -0700 (PDT) Received: from localhost (anonymizer2.torservers.net [173.244.197.210]) by mx.google.com with ESMTPS id x39sm868483vcr.29.2010.07.02.08.35.06 (version=SSLv3 cipher=RC4-MD5); Fri, 02 Jul 2010 08:35:08 -0700 (PDT) From: Anonymous To: Aiza References: <4C2D2839.3040909@comclark.com> Date: Fri, 02 Jul 2010 19:35:01 +0400 In-Reply-To: <4C2D2839.3040909@comclark.com> (Aiza's message of "Fri, 02 Jul 2010 07:43:53 +0800") Message-ID: <86ocepx5ga.fsf@gmail.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.0.50 (berkeley-unix) MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Cc: "questions@freebsd.org" Subject: Re: Bourne .sh ? X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 02 Jul 2010 16:06:07 -0000 Aiza writes: > I have a file containing this > > drwxrwxr-x 14 89987 546 512 Jun 6 2009 7.2-RELEASE > drwxrwxr-x 14 89987 546 512 Mar 23 04:59 7.3-RELEASE > drwxrwxr-x 13 89987 546 512 Nov 23 2009 8.0-RELEASE > drwxrwxr-x 13 89987 546 512 Jul 1 04:56 8.1-RC2 > > I want to strip off everything to the left of the release > version so I end up with this. > > 7.2-RELEASE > 7.3-RELEASE > 8.0-RELEASE > 8.1-RC2 > > How would I code to do this? Use... - glob expansion + echo builtin, e.g. $ cd /path/to/blah && echo * or $ cd /path/to/blah && for f in *; do echo $f; done - field splitting, e.g. $ ls -l | while read $(while [ $((i+=1)) -le 9 ]; do echo p$i; done); do echo $p9; done - stat(1) if you need not only filename but e.g. date Of course you can use smth like cut/sed/awk/whatever but they'll only make your script slower if you use them often.