1830207 Members
1878 Online
109999 Solutions
New Discussion

long command lines

 
SOLVED
Go to solution
Cody Godines_1
Occasional Advisor

long command lines

Hi everyone,
Sometimes I have a long command of the form:
ls dirpath ./
and the directory path is long. The next command I give might be of the form:
mv dirpath/file ./
You see, I can get back to the 'ls' command but I need to go to the beginning of the line to change 'ls' to 'mv'. Is there a way to quickly jump from the beginning to the end of a line? Or even to stop at every '/'? I just want to be more efficient, so every little bit counts, and any type of answer will be most appreciated.
By the way, Brant Evans, Bill Hassell, Ian Kidd, Shannon Petry, and Michael Tully, sorry about taking so long to assign points. I'll try not to let it happen again.
4 REPLIES 4
Rodney Hills
Honored Contributor
Solution

Re: long command lines

If you are in "vi" command mode, then-

0 (zero) - begining of line
$ - end of line
f/ - find next "/"

Be sure to press "esc" key to get into "vi" command mode.

-- Rod Hills
There be dragons...
Sachin Patel
Honored Contributor

Re: long command lines


If you are on vi then $ is end of line ^ is start of line.

if you have emacs as editor then on command line ctrl-a is beginning of line and ctrl-e is end of line

$ and ^ will work on bourne shell too, from command line i.e type command then hit esc (escape) key use $ and ^

Thanks
Sachin
Is photography a hobby or another way to spend $
Sajid_1
Honored Contributor

Re: long command lines

hello,

If you are in vi mode (ksh -o vi), you can repeat the old commands and then move to the last with 'shift+A' command. This is actually append mode from the end of line, but if you press 'esc', then it will return you to the end of line and then use 'vi' commands for manipulation.
learn unix ..
James R. Ferguson
Acclaimed Contributor

Re: long command lines

Hi Cody:

I assume that your shell's editor is set to be 'vi'. Given that, the key sequence "ESC K" will retrieve the last command from the .sh_history file for editting. Then "SHIFT A" will take you to the line's end.

Regards!

...JRF...