ksh in vi mode, choose from output


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers ksh in vi mode, choose from output
# 1  
Old 04-08-2006
ksh in vi mode, choose from output

is there a way to choose the complement from the output from the [ESC][=] sequense in "ksh -o vi"

root# ls
testa testb

root# cat tes[ESC][=]
1) testa
2) testb
root# cat tes <-- what to do now?
this output looks like a select function, otherwise the numbers wouldn't make sense, is there a chance to use the numbers?

gP
# 2  
Old 04-09-2006
Any numbered list will look like a select menu. There is no direct way to do anything with the list. (Cut and paste using x or windows doesn't count...the question is looking for functionality built into ksh itself.) There is a sequence of operations that can exploit that list somewhat. The only time I ever use it is just to show that it is possible. Most of the time you would be better off just typing "testb" or whatever. I usually work in emacs mode. But it looks like vi mode can do it too.

root# ls
testa testb

root# cat tes[ESC][=]
1) testa
2) testb
root# cat tes <-- what to do now?

Type * to replace "tes" with "testa testb" on the command line.

root# cat testa testb

Type [Esc][#] to turn the current line into a comment and drop it in your history file.

Now you retype your command but now you can extract words from the previous (commented) command in you history. Item n in the list you displayed is word n+1. So for example, "testb" is item 2 in the list and thus word 3 in the previous list. To extract word 3...

cat[Esc]3_

root# cat testb

Note that we did not need a space after the t in "cat". In this case, it so happens that we want the last word of the previous command. So we actually could have omitted the 3. The default is the last word. With enough complex filenames this technique could, in theory, be useful. I know, this isn't what you were looking for. But it is the the closest I can come to exploiting that numbered list of filenames.
# 3  
Old 04-19-2006
thanks for your answer Perderabo, but there is a way to work with that list, but i still don't know how Smilie (BTW, funny workaround Smilie )

the sequence i found would be [ESC][=]<number>[=], but for any strange reason, it is only working in some ksh versions....

i've tried it with the default ksh in solaris (/usr/bin/ksh) which is a ksh88 (Version M-11/16/88i) and it doesn't work.
so i've tried it in the ksh93 version of solaris (/usr/dt/bin/dtksh; Version M-12/28/93d, ksh93 + X, Xt, Xm and CDE functions). with the ksh93 that [ESC][=] also list matching executables from $PATH and shell functions(), but the select trick still doesn't work.
so i had a look on my gentoo box and compiled the newest version of pdksh (PD KSH v5.2.14-r4 99/07/13.2, no USEFLAGS only CFLAGS="-march=pentium4 -O2 -pipe -msse2 -mfpmath=sse -mmmx"), the list also comes up with $PWD, $PATH and f() but no luck with the selection. tried the same pdksh version on a BSD box, no luck....

B U T : Smilie

it is working in a pdksh on slackware (Version M 1993-12-28).... i found another ksh version in the solaris bolthole package tree, installed it, and guess what, it works with that ksh (Version M 1993-12-28 n+). i don't know what that "n+" stands for, but that would let me think about an environment settings or an profile setting, but looking at the "set" output i cannot find special settings....

anyone know how i could enable this behavior?
regards pressy
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

How to redirect output of a command to a variable during ftp mode?

Hi, How can I redirect the output of a following command to a variable. ftp myservername ftp> user (username) guptaji 331 Password required for guptaji. Password: ftp> size /home/salil/abc.dat ftp> a='size /home/salil/abc.dat' ?Invalid command I want to redirect value of size to... (1 Reply)
Discussion started by: Salil Gupta
1 Replies

2. Shell Programming and Scripting

Output in for loop (ksh)

Hi , I'm writing the for loop script in home directory and wanted to get the files from /etc/data directory. #!/bin/ksh file_nm="/etc/dat" for test_data in $file_nm/fln* do echo "$test_data" done the code is executing successfully , but in the output it is showing ... (6 Replies)
Discussion started by: smile689
6 Replies

3. Shell Programming and Scripting

set ksh script in restricted mode

Hi, I came across a post wherein you can use "set -r"(on bash) to activate restricted mode ( wherein you cant run some commands such as cd etc). Can anyone guide if we have anything similar in ksh ? Thanks (2 Replies)
Discussion started by: Shivdatta
2 Replies

4. Solaris

sqlplus output from ksh.

Hi All, I have the below simple script. It runs just fine by itself when I manually invoke it. But once I put it in the crontab with entry: * * * * * /users/myuser/test.ksh >> /users/myuser/log/test.txt" It does NOT print the returned value ($REMAIN) from the DB!? The result in the... (3 Replies)
Discussion started by: steve701
3 Replies

5. Shell Programming and Scripting

ksh/nawk help with if statement to choose between 2 files

Hi! I am having a bit of a problem with my script. There are two different date formats that may appear in a file, either Jul-12 or Jul--6. I tried to create an if statement that searches for one of the formats and if that doesn't exist searches for the other, however it doesn't seem to be... (3 Replies)
Discussion started by: ther2000
3 Replies

6. Shell Programming and Scripting

KSH script to run other ksh scripts and output it to a file and/or email

Hi I am new to this Scripting process and would like to know How can i write a ksh script that will call other ksh scripts and write the output to a file and/or email. For example ------- Script ABC ------- a.ksh b.ksh c.ksh I need to call all three scripts execute them and... (2 Replies)
Discussion started by: pacifican
2 Replies

7. Shell Programming and Scripting

Can ls in ksh write to output?

I have a ksh script written by someone... now i am trying to modify it to my requirement.... Its executed like this Read.ksh load ${CUR_MAINT_DATE} if then filnam="Load_CLM" else filnam="${1}" fi if then CUR_MAINT_DATE="${2}" fi if then ls... (1 Reply)
Discussion started by: bhagya2340
1 Replies

8. Shell Programming and Scripting

how can I choose output lines

Hello, I have a simple question, some scripts have information output on the first of command output such as: >copyrights by CFIL v1.0 > >1 >1 >1+1=2 How can I customize the output so I could delete the first line which has copyright line and also the second line which is blank for... (4 Replies)
Discussion started by: CFIL
4 Replies

9. Shell Programming and Scripting

ksh to bash mode

Hi guys... I have a ksh shell by default, so when I login to my unix box, all my .profile statements gets executed(including the aliases). But for some reasons(may be not comfortable using ksh), I would always switch to BASH(in the same session but as a child process) but in the process I am... (16 Replies)
Discussion started by: anduzzi
16 Replies

10. Shell Programming and Scripting

Formatted output in KSH

Hi, Is there some way to get formatted output in ksh? Something like a properly alligned tabular format. I tried adding '\t' to echo statements, but it doesn't come properly alligned 'hello' A simple Hello 'helloworld' A helloworld statement I need the second coloumn to... (1 Reply)
Discussion started by: psynaps3
1 Replies
Login or Register to Ask a Question