Matching command scroll - ksh


 
Thread Tools Search this Thread
Operating Systems AIX Matching command scroll - ksh
# 1  
Old 05-27-2010
Matching command scroll - ksh

In ksh is there a was to scroll thru all matching commands? For example I executed several commands over several days. Is there a way to scroll thru all the matching 'find' commands only that was executed?

No messing with the .history file. Anyway to do this from the command prompt? TIA.
# 2  
Old 05-27-2010
I have not always had 100% success with this and don't know the reasons why but it works way more than not.

If you don't have this set already, type

Code:
set -o vi

at the command prompt. I don't know the official term but this lets you scroll back through the command history.

Then type command below in two key strokes. Not both keys at the same time.

Code:
Esc k

This should recall the last command you executed from the command prompt.

If you just want to manually scroll though the command history hit
Code:
 n

for next.

Then if you want to search through the command history for something specific, like the last find command in stead of hitting "n" to scroll back though the list manually you would hit the forwardslash (/) and what specific value you are looking for like below.

Code:
root@foobar:/ $ /find

After typing the value simular to above hit enter and it should display the last "find" command that you executed. Then you would just keep hitting the letter "n" to display the next find command that you executed or possibly anyone else executed while logged in as that id if you happen to be using root.

Hope this helps.

Last edited by juredd1; 05-27-2010 at 03:01 PM.. Reason: correcting errors
This User Gave Thanks to juredd1 For This Post:
# 3  
Old 05-27-2010
Quote:
Originally Posted by juredd1
Code:
set -o vi

I don't know the official term
"VI command line editing mode". ;-)

Basically you have a vi-editor with only one line visible (and the history-file as text open) at the commandline. (Almost) every vi-command will work on the commandline too:

ESC (to set the editor from insert- to command-mode) and then:
  • k - a line up (therefore: last command)
  • j - a line down (therefore: next command, if you have already gone back some)
  • l - move cursor a character right
  • h - move cursor a character left
  • w - move cursor to first character of the word right to the cursor
  • b - move cursor to first character of the word left to the cursor
  • W/B - same as w/b but only taking whitespace as word boundaries into consideration
    This means: let text be "abc/def/ghi". If the cursor is on "g", then "w" brings you to the third "/", the next "w" to "d", etc., while "W" brings you to "a".
  • 0 - move to first character in the line

  • / - search through command history (all regexps allowed)
  • n - repeat last search and go to next hit
  • N - repeat last search and go to previous hit

  • i - reenter insert mode
  • a - append: insert right after cursor position
  • A - append at end of line

  • v - open a full vi with the command line as text (saving & exiting executes the command)
  • # - put a comment sign in front of the command and put it into history
    This won't execute anything, but saves a command(-part) for future use in the history file.

I hope this helps.

bakunin

Last edited by bakunin; 05-27-2010 at 10:02 PM..
These 3 Users Gave Thanks to bakunin For This Post:
# 4  
Old 06-01-2010
Thanks.

---------- Post updated at 01:39 PM ---------- Previous update was at 01:36 PM ----------

Quote:
Originally Posted by bakunin
"VI command line editing mode". ;-)
[*]/ - search through command history (all regexps allowed)

bakunin

This is what I was looking for. Thanks.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Unable to scroll to the top of the output of a command

Hello, I am a beginner, I have currently Solaris 11 on a vmware machine. Whenever I type a command like 'ls' the screen scrolls to the end of the screen. I am unable to see the entire list of directories and files. I have tried ls |page command, but looking out for a better option. (3 Replies)
Discussion started by: farheenprasad
3 Replies

2. Shell Programming and Scripting

Matching a block of data sed or ksh

I have the need to check content of very many files for a block of text. I know the data should match for instance/as an example the following The list of characters bugs bunny tom and jerry Mighty mouse Felix the cat / In the first step, I isolated the interesting data by... (3 Replies)
Discussion started by: popeye
3 Replies

3. UNIX for Dummies Questions & Answers

help with continous scroll

I figured out my question. mods please delete. Thank you (2 Replies)
Discussion started by: rpmischris
2 Replies

4. Shell Programming and Scripting

ksh Multiple Pattern Matching Operators

I figured this would be simple, but I am stuck. Variable longpath="/dir1/dir2/dir3/filename.stuff.morestuff.garbage" I want to end up with just "filename.extra.moreextra". So, I want to get rid of the path and .garbage I want to do this with just ksh internals. So, no sed,grep,awk,expr,... (4 Replies)
Discussion started by: Topaz
4 Replies

5. Shell Programming and Scripting

Changing the scroll limit in ksh

I don't have my SysV bible with me currently and I can't remember how to change the amount of lines visible in my shell. Currently I can only scroll back to see the last 100 lines of stdout. Any help is greatly appreciated. blessings, Tony <>< (2 Replies)
Discussion started by: port43
2 Replies

6. Shell Programming and Scripting

Pattern matching in ksh

In the Korn shell is it possible to truncate a pattern like this: - ) ]] So that it is not necessary to enter 8 times? (2 Replies)
Discussion started by: steadyonabix
2 Replies

7. Shell Programming and Scripting

awk/sed Command : Parse parameter file / send the lines to the ksh export command

Sorry for the duplicate thread this one is similar to the one in https://www.unix.com/shell-programming-scripting/88132-awk-sed-script-read-values-parameter-files.html#post302255121 Since there were no responses on the parent thread since it got resolved partially i thought to open the new... (4 Replies)
Discussion started by: rajan_san
4 Replies

8. AIX

aixterm scroll?

on a AIX sys i have been trying to get the mouse scroll wheel to page the terminal for about 2 yrs now on aixterm. any ideas. the below syntax does not work in aixterm but does work in xterm. ------------------------- this does not work in aixterm but does work in xterm,, with a cat Xdefult |... (2 Replies)
Discussion started by: nullwhat
2 Replies

9. UNIX for Dummies Questions & Answers

Seeing the screen output beyond the scroll capability for the last run command

HI , I forgot to redirect my op to a file.The op which is quite huge , thus printed on the screen.However bcoz of the limited viewing in the screenI can not see the whole of the output.. Is there anyway I can see the full op.My run takes half a day for finnishing ..So I am refraining... (1 Reply)
Discussion started by: bimukt
1 Replies

10. Shell Programming and Scripting

ksh pattern matching

I try to use the pattern substitution operators as documented in the O'Reilley "Learning the Korn Shell" but it doesn't seem to work as advertised. This works all right: var='Regular expressions rules!' $ echo ${var//e/#} R#gular #xpr#ssions rul#s! The docs says that using !(expr)... (5 Replies)
Discussion started by: ripat
5 Replies
Login or Register to Ask a Question