Sponsored Content
Full Discussion: how to test for backspace
Top Forums UNIX for Dummies Questions & Answers how to test for backspace Post 302398161 by anandkumar on Wednesday 24th of February 2010 01:51:11 AM
Old 02-24-2010
how to test for backspace

Hi all,

I am using a script which is as follows: It reads a character.
I want to check if the character is a backspace character or some other character.

read -n 1 x
if [ $x='\b' ]; then
echo "backspace detected"
else
echo "some other character"
fi

Thanks in advance.
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Backspace erasing the prompt

My AIX has Korn Shell. I had set the prompt by providing assigning to PS1. If on the prompt I use backspace it erase the whatever appeared due to PS1. Can someone tell me how to forbid this erasing of prompt string, with this behaviour? Thanks in advance. (4 Replies)
Discussion started by: videsh77
4 Replies

2. HP-UX

Backspace stty inconsistency

I have this in my .profile: stty erase `tput kbs` which sets erase to ^H for a vt and ^? for an xterm. This has been fine up until now on all systems whether I login using a vt terminal emulator or an xterm. On this new system though, if I log in directly using an xterm, backspace doesn't... (1 Reply)
Discussion started by: Runrig
1 Replies

3. UNIX for Dummies Questions & Answers

Control + h and Backspace

Hello, I am a UNIX newbie. With that out of that way.. In order to delete a mistyped character, I need to press control+h to move the cursor to the left, and then overwrite it. If I try hitting the backspace key, it just brings me to a new prompt. Is there a way to change it so that my... (1 Reply)
Discussion started by: martinp973
1 Replies

4. Shell Programming and Scripting

Backspace Key From Within Script

I have a script that asks a user for a few question. I would like the users to be able to use the backspace key if they make a mistake. Right now when they try they get ^? instead of it backing up. As you can see here from a stty -a the backspace is set... speed 38400 baud; rows = 42;... (2 Replies)
Discussion started by: LRoberts
2 Replies

5. Solaris

Using backspace in solaris - help

Hi In solaris if i have to delete something from shell i need to use ctrl+H, coz if i use backspace it shows ^?. Can any one please tell me how to set backspace key so that i can delete any character directly instead of using Ctrl+h. Second Q is like in linux for going to recent command, i... (10 Replies)
Discussion started by: sarbjit
10 Replies

6. Shell Programming and Scripting

Test on string containing spacewhile test 1 -eq 1 do read a $a if test $a = quitC then break fi d

This is the code: while test 1 -eq 1 do read a $a if test $a = stop then break fi done I read a command on every loop an execute it. I check if the string equals the word stop to end the loop,but it say that I gave too many arguments to test. For example echo hello. Now the... (1 Reply)
Discussion started by: Max89
1 Replies

7. Shell Programming and Scripting

How to check weather a string is like test* or test* ot *test* in if condition

How to check weather a string is like test* or test* ot *test* in if condition (5 Replies)
Discussion started by: johnjerome
5 Replies

8. UNIX Desktop Questions & Answers

backspace in vi search

Hi gurus, i use vi editor. when I want search something I Type / (or ? if i want search backward), that is OK. But when i make mistake in searching string how can i delete character ? I tried bacskpase but did not work (gives just strange characters). Also tried shift+bacskspace but this only... (3 Replies)
Discussion started by: wakatana
3 Replies

9. Shell Programming and Scripting

echo backspace

Hello Forum: I am trying to find a meaning to this echo escape character: echo -e "\b" Can someone tell me or give me examples of the effect that this has when used. I know that \b is the backspace, but I cannot visualise it use like any other escape such as: echo -e "\n" Thanks. --Willie (10 Replies)
Discussion started by: willie
10 Replies

10. Solaris

[SOLVED] Backspace not working!!!!!

Hi friends, Hope u r doing well. It is a very strange problem that I've never faced when I used linux or freebsd. When a type a command in Solaris 10, and if I make a mistake, the backspace doesn't work, when I press the backspace key three times forexample, this is what I get, ^H ^H ^H. The same... (2 Replies)
Discussion started by: gabam
2 Replies
curs_add_wch(3X)														  curs_add_wch(3X)

NAME
add_wch, wadd_wch, mvadd_wch, mvwadd_wch, echo_wchar, wecho_wchar - add a complex character and rendition to a curses window, then advance the cursor SYNOPSIS
#include <curses.h> int add_wch( const cchar_t *wch ); int wadd_wch( WINDOW *win, const cchar_t *wch ); int mvadd_wch( int y, int x, const cchar_t *wch ); int mvwadd_wch( WINDOW *win, int y, int x, const cchar_t *wch ); int echo_wchar( const cchar_t *wch ); int wecho_wchar( WINDOW *win, const cchar_t *wch ); DESCRIPTION
The add_wch, wadd_wch, mvadd_wch, and mvwadd_wch functions put the complex character wch into the given window at its current position, which is then advanced. These functions perform wrapping and special-character processing as follows: - If wch refers to a spacing character, then any previous character at that location is removed. A new character specified by wch is placed at that location with rendition specified by wch. The cursor then advances to the next spacing character on the screen. - If wch refers to a non-spacing character, all previous characters at that location are preserved. The non-spacing characters of wch are added to the spacing complex character, and the rendition specified by wch is ignored. - If the character part of wch is a tab, newline, backspace or other control character, the window is updated and the cursor moves as if addch(3X) were called. The echo_wchar function is functionally equivalent to a call to add_wch followed by a call to refresh. Similarly, the wecho_wchar is func- tionally equivalent to a call to wadd_wch followed by a call to wrefresh. The knowledge that only a single character is being output is taken into consideration and, for non-control characters, a considerable performance gain might be seen by using the *echo* functions instead of their equivalents. RETURN VALUES
All routines return the integer ERR upon failure and OK on success. NOTES
Note that add_wch, mvadd_wch, mvwadd_wch, and echo_wchar may be macros. PORTABILITY
All these functions are described in the XSI Curses standard, Issue 4. The defaults specified for forms-drawing characters apply in the POSIX locale. XSI documents constants beginning with WACS_ which are used for line-drawing. Those are not currently implemented in ncurses. SEE ALSO
curses(3X), curs_attr_get(3X), curs_clear(3X), curs_outopts(3X), curs_refresh(3X), putwc(3) curs_add_wch(3X)
All times are GMT -4. The time now is 02:54 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy