Select command with variable options having spaces or null contents
Hi,
I'm having an issue trying to produce a hierarchical directory menu that has either any directories listed in a specific directory as options or options with spaces in the option content or null content.
So the menu function gets passed a base directory, it then lists any .sh scripts in that directory or any other sub directories.
A select command lists the directories as seperate options, if there any shell scripts then an option "Run scripts in this dir" is given.
My problem is that if there are no shell scripts it gives a blank option in the select command, also a blank if there are no sub directories.
---------- Post updated at 12:55 PM ---------- Previous update was at 12:51 PM ----------
sorry, that line with REPLY should read $choice
---------- Post updated at 01:27 PM ---------- Previous update was at 12:55 PM ----------
I made some changes but still have the blank options problem
Its the blank option in the first iteration that I cant get, maybe I need just a single concatenated option in the select command but when I try it it seperates the options with spaces in into seperate selects...
Thanks but didn't help pinpoint what quotes I need around which variables..
The problem (as I see it, perhaps I'm looking at it wrong) is that I have say for example for variables being passed in the select command, one is a list one is a single word string, one is a string with spaces and one is either a string with spaces or nothing.
The list is done by having $var, the string is done by having "$var", however having "$var" means that a blank string is parsed if it contains nothing which select parses as a blank option... I think.
I have a text file with a line of text that contains numbers and text formatted into groups. I need to extract the number that can be either 1,2 or 3 digits long. Then write it to a variable, but i need to remove any leading spaces in the number first.
I can get the numbers out but how to remove... (12 Replies)
Hi one of the output of the command is as below
# sed -n "/CCM-ResourceHealthCheck:/,/---------/{/CCM-ResourceHealthCheck:/d;/---------/d;p;}" Automation.OutputZ$zoneCounter | sed 's/$/<br>/'
Resource List : <br>
*************************** 1. row ***************************<br>
... (2 Replies)
I want to select contents between two numbers say 1. and 2. from an output file which has many numbers but only the these two ending with a dot(.) eg 1. 2 . 32. etc I was looking to select with the use of a counter then modify the selected contents and put it in an output file where again the... (3 Replies)
Hi everyone I've two files..
The contents of file1 are as shown below
4
5
12
13
36
37
45
46
47
The contents of file2 are as shown below
21 hello
13 world (5 Replies)
Hi,
I am writing a shell script to build Java options dynamically in a variable array and pass them to java.exe. If an option value contains a space, I cannot find a way to get it interpreted correctly. Here is my example:
#!/bin/bash
JAVA_HOME=/opt/jvm/jre1.5.0_18
JAVA_OPTS=("-Xms256m... (4 Replies)
I suppose the easiest way to explain my problem is to show you some code and then show you what the code outputs:
--------------------------------------------------
#!/bin/bash
echo "This line has spaces" > "/tmp/This Filename Has Spaces.txt"
export Foo=$(cat "/tmp/This Filename Has... (4 Replies)
Hi,
I am facing difficulties in selecting the contents between two delimiters when there is a new line occurs..
Eg:
>more sample.txt
abcd -- this is the first line %
efgh-- this is the
second line and not
able to print %
ijkl -- this is the 3rd line %
when i search for abcd and... (8 Replies)
hi
i have records in my input file like this
aaa|1234||2bc||rahul|tamilnadu
bba|2234||b4c||bajaj|tamilnadu
what i am expecting is in between two pipes if there is no character it should be replaced with null or 0
so my file will look like this
aaa|1234|null|2bc|0|rahul|tamilnadu... (4 Replies)
I am trying to strip all leading and trailing spaces of a shell variable using either awk or sed or any other utility, however unscuccessful and need your help.
echo $SH_VAR | command_line Syntax.
The SH_VAR contains embedded spaces which needs to be preserved. I need only for the leading and... (6 Replies)
hi all,
i'm new to shell scripting, so i'm not sure how to work this. Is it possible to read in the contents of a variable and add it to a command? for example:
------------------------
#!/bin/sh
set example = -dfr
rm ${example}
------------------------
when i run the script, i want... (2 Replies)