Insert escaped characters in seq command separator
Posted
by
dhekir
on Super User
See other posts from Super User
or by dhekir
Published on 2012-12-12T16:37:37Z
Indexed on
2012/12/12
17:07 UTC
Read the original article
Hit count: 361
command-line
|terminal
How do I insert a string containing escaped characters (\n, \t, etc) as separator for the seq command?
The standard format includes a newline character:
$ seq 3
1
2
3
But if I try to add something plus a newline, the backslash is escaped and a literal "\n" is used instead:
$ seq -s "$\n" 3
1\n2\n3
The same happens using simple quotes, no quotes, or other escaped characters:
$ seq -s "\t" 3
1\t2\t3
$ seq -s \t 3
1t2t3
This is not the standard behavior for commands such as echo, so I'm a bit confused here...
Edit: Ideally, I'd like a somewhat portable solution (that works in tsch as well as bash, for instance), and without resorting to Perl or other languages.
© Super User or respective owner