Ctrl-v key on AIX

aixkshvi

I'm new to AIX and I miss some tricks that work well on other *nix flavors.

I need a CTRL sequence in a ksh scripts, like ^[ (CTRL-[) and to do that I'm habit to use the ctrl-v [ , but here it doesn't work.

At the moment I'm obliged to use a windows box with putty so I cannot even edit the scripts on my Linux box and transfer the scripts on the AIX server.

Do you know why and how I can fix the issue?

To resume the answers:

@Dennis:

there are a few other ways to use
escape in a Korn shell script:

print '\E' escape1='\033'    # contains the literal characters as shown
echo -e "$escape1"  
printf '%b' "$escape1"  
print "$escape1"
escape2=$'\e'     # contains an actual escape  
echo "$escape2"  
printf '%s' "$escape2"  
print "$escape2"  

For the terminal colors

man 5 terminfo

$'' notation allow ANSI-C escaping:

green=$'\e[01;32m'

It may be that ksh88 don't support $''

I use a ksh88, but I can switch to ksh93.

ctrl-v on command line
Version M-11/16/88i 

/usr/dt/bin/dtksh
print ${.sh.version}
Version M-12/28/93d

green=$'\e[01;32m' doesn't give me any error on ksh88,

but it doesn't expand the escape sequence.
On ksh93 $'' the same issue

green="$'\e[01;32m'"

Using uppercase E solved the issue (weird!!!):

print $'\E[01;32m hello'

To summarize:

\E  works
\e  NO
\033    works just with echo
^[     ^v^[ do not work at all

Best Answer

Try this:

stty -a

and see if lnext is ^V. If not, try:

stty lnext ^V

where you will type "^" (caret) and "V" as separate characters. Now try to see if you can type an escape using ^V^[ (does ^VEsc work on your keyboard?).

Also, check to see if you're in emacs mode

Depending on how you're using it, there are a few other ways to use escape in a Korn shell script:

print '\E'
escape1='\033'    # contains the literal characters as shown
echo -e "$escape1"
printf '%b' "$escape1"
print "$escape1"
escape2=$'\e'     # contains an actual escape
echo "$escape2"
printf '%s' "$escape2"
print "$escape2"

Of course, you wouldn't normally output escape all by itself.

Related Topic