How to use a multiple line list with the select command in ksh?
I copied the below program to play around with displaying a list of items using the select command in ksh. When I put all items in the same line, it works fine. I am trying to use multiple lines instead of a single row...my list is too large for a single line. How do I get the line continuation to work properly. The initial script used a "\" at the end of the 2nd, 3rd, and 4th lines in the "select" command...this only displayed the "\" before the ^J. I took the "\" out, but that didn't change the output format. Here's the code:
I have also tried removing the single quotes that surround the list in the select command, but this returns the syntax error:
termname.sh[8]: syntax error at line 9 : `newline or ;' unexpected
Any help would be greatly appreciated.
Thanks,
Jeff
Last edited by vbe; 08-23-2013 at 12:56 PM..
Reason: code tags please for your code and data
Instead of using single quotes around all of the terms, simply continue the list by ending each line of the list, except the last, with a backslash (you can use this to continue any shell command).
alister...thank you so much. The original code did not have a "\" after "select term in"...which is the first line in the command. I could've sworn that I tried that, but after countless changes, I needed a new set of eyes. Works like a charm.
One more question. If you don't have a quick fix, you can tell me to do another post, but, I wanted to know if there is a way to display a multi-column list? Would I use select again or something else?
I am trying to have the user select two files from a numbered list which will eventually be turned into a variable then combined. This is probably something simple and stupid that I am doing.
clear
echo "Please Select the Show interface status file"
select FILE1 in *;
echo "Please Select the... (3 Replies)
I am looking for help in processing of those options: '-n' or '-p'
I understand what they do and how to use them.
But, I would like to use them with more than one file (and without any shell-loop; loading the 'perl' once.)
I did try it and -n works on 2 files.
Question is:
- is it possible to... (6 Replies)
here is what i want to achieve.. i have a file with below contents
cat fileName
blah blah blah
.
.DROP this
REJECT that
.
--sport 7800 -j REJECT --reject-with icmp-port-unreachable
--dport 7800 -j REJECT --reject-with icmp-port-unreachable
.
.
.
more blah blah blah
--dport 3306... (14 Replies)
I have a huge file and I want to select first 10 charcters and last 2 characters of everyline and than will filter the unique line.
I know, it must be easy bt I am new to unix scripting:)
Ex.
I have file as below and need to e3kbaird and last 2 characters. and than unique records.
... (3 Replies)
Hi.
I have a ksh script I want to run, but I'm connecting through a telnet and I don't want to FTP the scripts itself.
is there a way of running the script from command line ?
like ksh "The script itself..."
Thanks,
Ramon (4 Replies)
Hi I am executing a KSH script by passing command line arguments
example: Red Green Dark Red Blue
when I am splitting the arguments by using " "(Space) as delimiter
But the colour Dark Red is a single parameter. But it is getting splitted in between
How to avoid this. Please help Also... (4 Replies)
hi. i'm using ksh with set -o vi. if i am far down in a directory and try to edit the command line (esc-k to retrieve previous command) the cursor is being positioned over to the left on top of the directory text making the text very difficult to read or work with. seems to be problem with long... (2 Replies)
Hi -
I have a file that contains data in this format:-
#comment
value1 value2 value3
#comment
value4 value5 value6 value7
#comment
value8 value9
I need to read value1, value2 and value3 into one array, value4 value5 value6 and value7 into another array and value8 and value9 into a 3rd... (2 Replies)
How would I go about storing multiple file paths in a directory that begin like: 20080402*
and run a loop that reads each line of each file thats in a given directory. So far this is what I have:
#!/bin/ksh
echo "ENTER Reprint Date (YYYYMMDD): "
read ReprintDate
echo ""... (1 Reply)