Delete/backspace on command line



  • 1. How to access /dev/fd/0 or /dev/stdin in cygwin
    Hi All, I want to implement a function in my script running in cygwin, which can read from either normal files or pipes and here documents. In linux, the function can be implemented as: ------------------------------------------------------------------- function my_cat() { local file if [ -z "$1" ]; then file=/dev/fd/0 else file=$1 fi cat $file } ------------------------------------------------------------------- but this can't be run in cygwin bash shell. Bash says: cat: /dev/fd/0: No such file or directory So, how can I access the device /dev/fd/0 in cygwin. BTW, /dev/null and /dev/urandom can be accessed in the same shell. My cygwin version is: GNU bash, version 3.00.16(14)-release (i686-pc-cygwin) Copyright (C) 2004 Free Software Foundation, Inc. Best Regards PRC Jul 24, 2008
  • 2. I need to have double quotes around a value from an awk command...any ideas...
    I have the following command: df | sed 1d | awk '{print "insert into mysql.dba_diskspace values (curdate()," $4"," $6 ");"} And the output looks like: insert into mysql.dba_diskspace values (curdate(),3051648,/); insert into mysql.dba_diskspace values (curdate(),1890052,/tmp); insert into mysql.dba_diskspace values (curdate(),3778052,/home); insert into mysql.dba_diskspace values (curdate(),3729632,/var); insert into mysql.dba_diskspace values (curdate(),173052,/boot); insert into mysql.dba_diskspace values (curdate(),8192960,/dev/shm); insert into mysql.dba_diskspace values (curdate(),663166552,/mysql); But my output should look like: insert into mysql.dba_diskspace values (curdate(),3051648,"/"); insert into mysql.dba_diskspace values (curdate(),1890052,"/tmp"); and so on and so forth. I tried multiple choices, but I can not get the output I like, any body knows who to? Thanks in advance. Best regards, Carlos R. Jimenez.
  • 3. HowTo: Update parameters by script in config file?
    Dear subscribers I was thinking about the best way to update parameters in a config file using a script. Assume you have a config file like: #Comment PARAM1=Value1 PARAM2=Value2 #Comment 2 PARAM3=Value3 ... .. This file can be incorporated easily in a script by sourcing it but assume I would like to interactively ask the user for values from a script and automatically update values in the config file, similar to "configure" which sometimes precedes a "make", what is the best way to update the parameters of the config file? E.g. I'll like to change the value of PARAM2 to "Calvin" using a script. Would it be to to a search- and-replace operation using e.g. Pearl from the script or is there some other "standard method" to do this? Regards, Ola
  • 4. Not to display the results at top of the screen
    Hi, I am using SUN OS 5.10 and putty to connect to the server. When I execute any query in sqlplus prompt it always displays the result at top of the screen. That means if I execute another query it push back the old results and displays the new output at top of the screen. I am able to see the old results by scrolling the screen. But I want my new results to be displayed below the old result without pushing it back. Anyone have any idea on this. Thanks in advance.
  • 5. quick sed question
    At least, I think this will be a quick question. I want to use sed to insert a line after the first occurrence of a pattern, and only that one time. For example - I want to insert the line "##########" before the first occurrence of a line starting with "Beta": ---------------------------------- Alpha Beta Beta Gamma Theta Theta Beta ---------------------------------- Should become: ---------------------------------- Alpha ########## Beta Beta Gamma Theta Theta Beta ---------------------------------- I've tried many things, the closest I've come is this: sed -e'/^Beta/i ##########' -e'/^Beta/q' inputfile But that quits after doing the insert, and the rest of the file is omitted. Surely this is straightforward with Sed? And yes, I know that there are many other ways of doing this, but I'd like to fill the gap in my Sed knowledge here. Thanks!

Delete/backspace on command line

Postby Sashi » Thu, 19 Jun 2008 21:47:57 GMT

Hi all,
When running a command line tool such as bc or sqlplus, I can't use
the backspace key or the delete key to erase the previously typed
Backspace gives me ^? and delete gives me [[3~.
I know that in bash I can use the 'stty erase' command to set this
right but how do I do it in other tools?
I sometimes have this problem on the vim command line too, but IIRC,
vim can be corrected using fixdel.
Is there a generic way that works across tools?
I'm using putty. (I know this would make some people's lip curl

Re: Delete/backspace on command line

Postby Stephane CHAZELAS » Thu, 19 Jun 2008 21:54:37 GMT

2008-06-18, 05:47(-07), Sashi:

stty erase '^?'

will work for the other tools to.

Apparently, your system's default tty settings expect
<Backspace> to send the BS character instead of the DEL one.

You can either change that with the stty command, or you could
tell your putty to send BS (^H) upon <Backspace>. See in the
configuration menus.

What is possible as well is that the terminfo database for your
value of $TERM tells the application that your backspace key is
^H. In that case, changing the putty behavior is probably the
best option.


Re: Delete/backspace on command line

Postby Joachim Schmitz » Thu, 19 Jun 2008 23:25:06 GMT

In PuTTY you can quite easily change what PuTTY sends when you hit the 
Configuration/Terminal/Keyboard, there you can switch beetween sending 
Control-H and Control-?

AFAIR PuTTYs's default is ^?, which I found quite disturbing...

Bye, Jojo 

Re: Delete/backspace on command line

Postby Chad » Thu, 19 Jun 2008 23:54:57 GMT

On Jun 18, 5:54m, Stephane CHAZELAS < XXXX@XXXXX.COM >

Would the value of $TERM, which could be ^H on the client side,
possibly override the value of $TERM on the server side?


Re: Delete/backspace on command line

Postby Stephane Chazelas » Fri, 20 Jun 2008 00:21:51 GMT

2008-06-18, 07:54(-07), Chad:

$TERM is set by the client, it's passed in all the rlogin, ssh
and telnet protocols.

But what sometimes happen is that systems don't agree on what
this or that terminal behaves. For instance, one system may know
"xterm" as a terminal that sends ^H upon bs, while on another as
one that sends ^? instead.

Also, the value of $TERM on one system may not have a terminfo
entry in another system. For instance, some systems have a
"putty" entry, some haven't.

In the putty configuration, you can choose which value of $TERM
to use. You should use one for which on the target system,
there's a terminfo entry that describes as closely as possible
the putty terminal in its current emulation.

It's also possible to install *the* correct entry for "putty" on
the target system (which you can probably download from the
putty web site), either system-wide or in your own terminfo
database (see the $TERMINFO variable for how to setup your
private terminfo database).


Re: Delete/backspace on command line

Postby Chad » Fri, 20 Jun 2008 04:07:43 GMT

On Jun 18, 8:21m, Stephane Chazelas

Is there some kind of magical rule that happens when the two systems
don't agree? If not, how do the the systems resolve the 'conflict'?


Re: Delete/backspace on command line

Postby Maxwell Lol » Fri, 20 Jun 2008 11:01:40 GMT

Chad < XXXX@XXXXX.COM > writes:

You can test the value of $TERM, and the current host, and OS, and set
the value to the one you want. If an HP systems does one thing, and a
SOlaris does another, you can test this.

Sometimes I look for a file like .local.$HOSTNAME, and if it exists, I
execute the shell commands inside.

Re: Delete/backspace on command line

Postby Teddy » Fri, 20 Jun 2008 19:30:52 GMT


Check all your rc file and default shell which they use.
I also faced this problem when I was given a new server which uses
Every time I invoke some application tty settings gets revert.

So I putted below line in all .rc files.
stty erase ^H

Also if that doesnt work then last solution I suggest is dont use
backspace or delete
use ctrl+H key . This will delete back one word no matter which
terminal you are using.

Similar Threads:

1.VI at the command line and backspace

SunOS action9 5.8 Generic_108528-29 sun4u sparc SUNW,Sun-Fire-V240

How to I enable vi as my default command line editor and keep the back space
from echoing ^H instead of moving the cursor back one Char.



2.delete multiple lines with perl (was: delete multiple lines with sed)

3.Delete directories in different folders in single command line


I would like to delete ".svn" in current directory and all sub-
directories. First, I tried to redirect the result from "find" command
to rm but it didn't work. Does anyone have any idea how to do the job
in single command line?


[lkk@server svntest]$ find . -name .svn
[lkk@server svntest]$ find . -name .svn | rm -rf
[lkk@server svntest]$ find . -name .svn
./trunk/cc/.svn   <---it's still here...

4.KDE/Gnome or the Command Line? (was: [delete]

Return to unix


Who is online

Users browsing this forum: No registered users and 91 guest