3

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?

1 Answer 1

5

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
1
  • Very nice; thank you!
    – josmith42
    Commented Nov 29, 2019 at 14:04

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .