1

I am wondering if there is a concise way to output the elements of a fish list on separate lines.

I know I can do e.g. echo $PATH | tr ' ' '\n' to achieve the desired output, e.g.:

/usr/local/sbin
/usr/local/bin
/usr/local/games
/usr/sbin
/usr/bin
/usr/games
/sbin

but this seems cumbersome. And I'm also guessing it will break if elements contain spaces. Is there a more concise, correct, and fish built-in way to do this?

3

printf "%s\n" $PATH is what you're looking for.

It does respect elements with spaces:

$ set x "a b" "C d"
$ printf "%s\n" $x
a b
C d
  • Very nice; thank you! – josmith42 Nov 29 at 14:04

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.