Re: simple trick



On Sat, 24 Mar 2007, in the Usenet newsgroup linux.redhat, in article
<4605cd0b$0$24772$4c368faf@xxxxxxxxxxxxxx>, Matt Giwer wrote:

And probably very old but I just came across it.

C and Korn shell - mid 1980s

Create a new file but any of the obvious ways would contaminate it with
at least one byte AND the file names is something like 50 characters
long so I have to type it without error.

So first I us ls and tab completion to get the right file and hit return.

OK

Then I up arrow to get that last command and backspace through it to the
ls. I erase the ls and replace it with > the greater-than caret/arrow
and I have a zero byte file.

Other Bash tricks

1. Press the '>' key, a space, then use tab completion (though in
reality, most people would feel more comfortable verifying that the tab
completion is going to do the right thing before they blast a file).

2. Write in whatever your "new" command is plus the separating space,
then press the right Alt and period keys together to copy the last
argument from the previous command.

3. Press the ^ key (shift 6), write the crap that you want to replace,
then press the ^ key key again, followed by the "new" crap.

[compton ~]$ echo '111' > FOO
[compton ~]$ cat <--- press 'Alt' and '.' together, which gives
[compton ~]$ cat FOO
111
[compton ~]$ ^cat^rm
rm FOO <--- the shell shows the result of the substitution
[compton ~]$ !cat <--- repeat the last command that began with 'cat'
cat FOO <--- shell says "that must be this one"
cat: FOO: No such file or directory
[compton ~]$

It's all in the man page for the Bash shell - try 'man bash'

If the command line is wrong, you can either backspace out of it, or just
press the left Ctrl and 'u' keys together to erase the command.

Old guy
.



Relevant Pages

  • Re: OneFinger - the graphical shell
    ... >> i.e. bash, but bash is also very powerful and to me its powerfull enough ... >> (its also does caching, narrowing, ... tab completion has always been a kind of pain to me. ... options as with command completion when there is more than one ...
    (comp.os.linux.misc)
  • Re: double-tab Command in Linux
    ... > I recently found out about a command in Linux and apparently Solaris that ... It's tab completion, and it's present in shells, editors, and surely ... Read the "programmable completion" part of man bash for ... In bash, it's far more powerful than just listing ...
    (comp.os.linux.misc)
  • Re: [MSH] Tab Completion in MSH vs. Bash
    ... One thing that got my annoyed though was the command / tab completion. ... Since I'm no new to Monad I might just be wrong about this, but the completion in Monad seems to work the same way it did in Windows 2k/xp/2003. ... Since there are so many other improvements in monad I guess I was hoping for some better command completion. ... I think it would be better if it worked the same way as it does in bash, if I see all the options on screen I get where I want faster. ...
    (microsoft.public.windows.server.scripting)
  • Re: USB neu starten
    ... PCI Interrupt Link enabled at IRQ 7 ... bash: SLPB: command not found ... bash: syntax error near unexpected token `supports' ... achim@achim:~$ ReiserFS: hdc5: found reiserfs format "3.6" with standard journal ...
    (de.comp.os.unix.linux.hardware)
  • [gnu.bash.bug] BASH Frequently-Asked Questions (FAQ version 3.30)
    ... This is the Bash FAQ, version 3.30, for Bash version 3.0. ... Bash, the GNU Bourne-Again Shell. ... C3) Which new features in ksh-93 are not in bash, ... D1) Why does bash run a different version of `command' than ...
    (comp.unix.shell)