From owner-freebsd-questions Tue Dec 28 13:10:49 1999 Delivered-To: freebsd-questions@freebsd.org Received: from dorifer.heim3.tu-clausthal.de (dorifer.heim3.tu-clausthal.de [139.174.243.252]) by hub.freebsd.org (Postfix) with ESMTP id A013814D67 for ; Tue, 28 Dec 1999 13:10:46 -0800 (PST) (envelope-from olli@dorifer.heim3.tu-clausthal.de) Received: (from olli@localhost) by dorifer.heim3.tu-clausthal.de (8.8.8/8.8.8) id WAA28363 for freebsd-questions@FreeBSD.ORG; Tue, 28 Dec 1999 22:06:44 +0100 (CET) (envelope-from olli) Date: Tue, 28 Dec 1999 22:06:44 +0100 (CET) From: Oliver Fromme Message-Id: <199912282106.WAA28363@dorifer.heim3.tu-clausthal.de> To: freebsd-questions@FreeBSD.ORG Subject: Re: Is there a way to do this using ls command ? Organization: Administration TU Clausthal Reply-To: freebsd-questions@FreeBSD.ORG MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit X-Newsreader: TIN [version 1.2 RZTUC(3) PL2] Sender: owner-freebsd-questions@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG Joss Roots wrote in list.freebsd-questions: > hi there, > I am trying to make a shell script get the names > of directories from a certain path; > [...] > 1. don't include, or otherwise strip, all entries > that are NOT directories, so as NOT to save them > in the generated output file > for example ls -F | grep / > (but this will output a trailing / after each and > every directory name), so how to strip this > can this be done using sed, or something else ? ls -F | sed -n s./..p That will give you all directories and strip the slashes at the same time. > 2. Remove certain directory entries form the > list, for example CVS/ , pkg/ > before saving the final output to the file. Just pipe the above through an appropriate grep command: ... | egrep '^(CVS|pkg)$' > 3. the list must be sequential listing one entry > on a seperate line. (like issuing simple ls) The above does exactly that. Use shell direction to store the output in a file: ... > output_file Regards Oliver -- Oliver Fromme, Leibnizstr. 18/61, 38678 Clausthal, Germany (Info: finger userinfo:olli@dorifer.heim3.tu-clausthal.de) "In jedem Stück Kohle wartet ein Diamant auf seine Geburt" (Terry Pratchett) To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-questions" in the body of the message