Corrections when using Line Continuation

Corrections when using Line Continuation

Post by john.jc » Sun, 25 Jun 2006 04:13:50



How do I go back to previous lines when using line continuation.

Say for example I have this command:

# find / -type f | \

Quote:> gep -i 'grepped string' | \
> wc -l

and before I execute the command I realize that I have a typo on the
second line.  How am I able to go back to that line to make the
correction without having to Ctrl-C and start over again?

Thanks a lot,

--John

 
 
 

Corrections when using Line Continuation

Post by Chris F.A. Johnso » Sun, 25 Jun 2006 05:13:33



> How do I go back to previous lines when using line continuation.

> Say for example I have this command:

> # find / -type f | \
>> gep -i 'grepped string' | \
>> wc -l

   You don't need the backslashes after the pipe.

Quote:> and before I execute the command I realize that I have a typo on the
> second line.  How am I able to go back to that line to make the
> correction without having to Ctrl-C and start over again?

   I press Ctrl-C, then press the up arrow and edit what I had
   entered.

--
   Chris F.A. Johnson, author              <http://cfaj.freeshell.org>
   Shell Scripting Recipes: A Problem-Solution Approach (2005, Apress)
   ===== My code in this post, if any, assumes the POSIX locale
   ===== and is released under the GNU General Public Licence

 
 
 

Corrections when using Line Continuation

Post by Steve Alla » Sun, 25 Jun 2006 05:51:55



>How do I go back to previous lines when using line continuation.

>Say for example I have this command:

># find / -type f | \
>> gep -i 'grepped string' | \
>> wc -l

>and before I execute the command I realize that I have a typo on the
>second line.  How am I able to go back to that line to make the
>correction without having to Ctrl-C and start over again?

It can be done in zsh, using the command push-line-or-edit. It's
typically not bound, so you'd want to bind it to some key, e.g.

  bindkey '\eq' push-line-or-edit

would bind it to Esc-q.  Once bound, typing Esc-q would allow you to
edit the entire command as if it were all one line.

Of course, if you're not using zsh then that doesn't help much :)  I
don't know if/how it can be done in bash or ksh.

--
-- Steve

 
 
 

1. sh line continuation

A friend of mine has this scriptlet in his signature:

--- hanoi.sh -->
m(){ if [ $1 -eq 1 ];then echo $2 $3;else m $(($1-1)) $2 $4 $3;m 1 $2 \
$3 $4;m $(($1-1)) $4 $3 $2;fi;};if [ $# -eq 3 ]&&[ $3 -ge 1 -a $1 -le \
3 -a $1 -ge 1 -a $2 -le 3 -a $2 -ge 1 -a $1 -ne $2 ];then m $3 $1 $2 $\
((6-$1-$2)); else echo Usage: /bin/sh hanoi.sh from to num; fi #by rhb
<---------------

The line continuation from the third to the fourth line is something of
a problem:

... $\
((...))

pdksh and bash accept this as a valid expression for arithmetic
substitution.  FreeBSD's sh and ksh93 complain about a syntax error.
Does POSIX have anything to say about this?

--

2. DigiTemp v3.1.0 Release

3. Newbie needs bash line continuation help.

4. Boot problem

5. Joining continuation lines

6. setting up TCP?

7. Line continuation - not !

8. CERN protection

9. dfstab entries too long, is there a line continuation feature?

10. line continuation for a string in bash

11. Continuation Lines

12. line continuation "\" on #defines

13. Collapsing continuation lines (