Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: for loop file order



A solution I use for processing file names in the shell is to use “find” to print them with a null-character terminator and then use zsh’s read command with “no” delimiters, as in:

	find . -depth 1 -print0 | \
		while read -d '' File; do
			echo $File
		done

Note the “’’” there is two apostrophes, not a quotation mark.

That leaves them in the order “find” finds them, but you can insert a sort (with -z) as desired.

				— edp (Eric Postpischil)
				https://edp.org

You are on a rock floating through space.





Messages sorted by: Reverse Date, Date, Thread, Author