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

Re: Surely this can be done easier...



On Dec 24, 10:10pm, DervishD wrote:
}
}     I have a file containing a list of files, and I want those files
} in a command line. The problem is that the filenames contain weird
} characters, spaces and so on.

This is pretty close to a FAQ.

First you read the entire file like this:

	$(<listing)

Next you need to quote that to protect the lines from being joined:

	"$(<listing)"

Next you split on line breaks:

	${(f)"$(<listing)"}

And that's the argument of the command:

	command ${(f)"$(<listing)"}

In some older versions of zsh you need to move the quotes outside the
whole expression:

	command "${(f)$(<listing)}"



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