1 |
On 2016-12-19 21:49, lee wrote: |
2 |
|
3 |
> > [5+0]~$ FOO='foo,bar,baz' |
4 |
> > [6+0]~$ printf '%s\n' `echo $FOO | tr ',' ' '` |
5 |
> > foo |
6 |
> > bar |
7 |
> > baz |
8 |
> |
9 |
> Nice, thanks! |
10 |
> |
11 |
> I never realised there's printf and always wondered why I needed man 3 |
12 |
|
13 |
In fact you don't even need printf for this: |
14 |
|
15 |
[3+0]~$ echo 'foo,bar,baz' | tr ',' '\n' |
16 |
foo |
17 |
bar |
18 |
baz |
19 |
|
20 |
> Hm. Does anyone know when printf was written? The man page seems to be |
21 |
> wrong: |
22 |
> |
23 |
> [~] printf --version |
24 |
> bash: printf: --: invalid option |
25 |
> printf: usage: printf [-v var] format [arguments] |
26 |
|
27 |
That's because bash has a printf builtin. This works: |
28 |
|
29 |
[1+0]~$ /usr/bin/printf --version |
30 |
printf (GNU coreutils) 8.25 |
31 |
Packaged by Gentoo (8.25 (p1.1)) |
32 |
Copyright (C) 2016 Free Software Foundation, Inc. |
33 |
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>. |
34 |
This is free software: you are free to change and redistribute it. |
35 |
There is NO WARRANTY, to the extent permitted by law. |
36 |
|
37 |
Written by David MacKenzie. |
38 |
|
39 |
-- |
40 |
Please *no* private Cc: on mailing lists and newsgroups |
41 |
Personal signed mail: please _encrypt_ and sign |
42 |
Don't clear-text sign: http://cr.yp.to/smtp/8bitmime.html |