Date: Tue, 28 Dec 1999 22:06:44 +0100 (CET) From: Oliver Fromme <olli@dorifer.heim3.tu-clausthal.de> To: freebsd-questions@FreeBSD.ORG Subject: Re: Is there a way to do this using ls command ? Message-ID: <199912282106.WAA28363@dorifer.heim3.tu-clausthal.de>
next in thread | raw e-mail | index | archive | help
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
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199912282106.WAA28363>