Using for in one-liner

BranoZ zarnovican at gmail.com
Mon Aug 15 14:22:02 EDT 2005


Paul Watson wrote:
> Using a '$' before the string works in the ksh that is part of FC4.
> However, it does not work on the pdksh that is in FC3 and Cygwin.  It
> also does not work on AIX ksh.
>
> $ print $'now'
> $now

In bash you can also use Ctrl-v followed by special character.
(I used to reset terminal by echo "<Ctrl-v><Esc>c"<Enter>)

Ctrl-v, Enter -> generate 0x0d to command-line
Crtl-v, Ctrl-m -> the same as above
Ctrl-v, Ctrl-j -> generate 0x0a (UNIX \n)

So type:
python -c 'import sys;
then press Ctrl-v followed by Ctrl-j
and type the rest..

In vi it looks like ^@. At CLI it realy does a newline.
I guess, you can no longer call it an one-liner ;-)

I'm not sure whether Ctrl-v is a bash feature. More probably
the tty driver. So, it may be worth tring it on bash-less UNIXes
(that deserve to extinct)

BranoZ




More information about the Python-list mailing list