How to select strings with space?


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting How to select strings with space?
# 1  
Old 05-09-2005
How to select strings with space?

Hi folks,

I have the following select function:
select_vs_plugin()
{
export VS_LIST=`cat VsList.lst`
while [[ "1" = "1" ]]
do
echo
echo
echo ===================================================================
============
echo Please select Video Server Plugin
echo ===================================================================
============
echo
select selectedVsPlugin in $VS_LIST Quit
do
if [[ -z "${selectedVsPlugin}" ]] ; then
echo "\n**** !! Invalid Option !! ****\n"
else
break
fi
done
if [[ ${selectedVsPlugin} = "Quit" ]] ; then
echo "\n**** End of video servers selection ****\n"
break
else
export SELECTED_VS=${selectedVsPlugin}
echo The select video server plugin is : ${SELECTED_VS}
fi
done
}

The configuration file VsList.lst contains the following video servers names:
MediaBase XMP 7.2
Maestro 4
SeaChange iTV 2.5

The function suppose to display those names in selection menu.
Now,the selection diplaying looks as the following:
===============================================================================
Please select Video Server Plugin
===============================================================================

1) MediaBase
2) XMP
3) 7.2
4) Maestro
5) 4
6) SeaChange
7) iTV
8) 2.5
9) Quit
#?


The wrapped displaying occured due to the space in the names in tthe lst file.

How can i overcome on this space problem?

Thanks in advance.

Nir
# 2  
Old 05-09-2005
Change the IFS variable setting as,

export IFS='
'

It will work.
# 3  
Old 05-09-2005
Hi muthukumar,

Thanks for your reply!
I didn't understand the meaning of "IFS parameter".
To which parameter did you mean?

Thanks in advance,
Nir
# 4  
Old 05-09-2005
IFS is default shell parameter to give strings patterns based on the field separator. You are doing operation as, export VS_LIST=`cat VsList.lst` so that it will take ' ' <space> as FS so try to change newline to do your work.
# 5  
Old 05-09-2005
Thanks again muthukumar!

Frankly,i'm looking for a solution that not require a shell parameters changing,because it might harm other functions in the program.

Any other solutions will be greatefully accepted.

Nir
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

How to pass strings from a list of strings from another file and create multiple files?

Hello Everyone , Iam a newbie to shell programming and iam reaching out if anyone can help in this :- I have two files 1) Insert.txt 2) partition_list.txt insert.txt looks like this :- insert into emp1 partition (partition_name) (a1, b2, c4, s6, d8) select a1, b2, c4, (2 Replies)
Discussion started by: nubie2linux
2 Replies

2. Shell Programming and Scripting

Search and repllace of strings with space between words

Dear all, I have gone through all the search and replace requests but none of them meet my particular need. I have a huge file in which all Unicode characters are stored as Names. A sample is given below. I want to replace strings in that file with a mapper from another file termed as master.dic. ... (4 Replies)
Discussion started by: gimley
4 Replies

3. Shell Programming and Scripting

Compare strings with space in if statement

DEV> vi test_if_statement.sh "test_if_statement.sh" 9 lines, 205 characters proc_out="Normal completion" proc_out_comp="Normal completion" echo 'proc_out:'$proc_out echo 'proc_out_comp:'$proc_out_comp if then echo 'match' else echo 'no_match' fi ~ ~ ~ ~ ~ ~ ~ ~ ~ (4 Replies)
Discussion started by: cartrider
4 Replies

4. Shell Programming and Scripting

Delete lines in file containing duplicate strings, keeping longer strings

The question is not as simple as the title... I have a file, it looks like this <string name="string1">RZ-LED</string> <string name="string2">2.0</string> <string name="string2">Version 2.0</string> <string name="string3">BP</string> I would like to check for duplicate entries of... (11 Replies)
Discussion started by: raidzero
11 Replies

5. UNIX for Dummies Questions & Answers

Delete strings in file1 based on the list of strings in file2

Hello guys, should be a very easy questn for you: I need to delete strings in file1 based on the list of strings in file2. like file2: word1_word2_ word3_word5_ word3_word4_ word6_word7_ file1: word1_word2_otherwords..,word3_word5_others... (7 Replies)
Discussion started by: roussine
7 Replies

6. Shell Programming and Scripting

How to preserve space while concatenating strings? (KSH)

I have these str1=$(echo "This is string one with spaces \n This is also my sentence 1") When I echo $str1, it displays the new line character properly. Now I have another new variable say str2. I want to concatenate in this way.. str1 + newline character + and then str2. That's I... (3 Replies)
Discussion started by: dahlia84
3 Replies

7. Shell Programming and Scripting

Extract lines between 2 strings add white space

I'm trying to extract all the lines between 2 strings (including the lines containing the strings) To make the strings unique I need to include white space if possible. I'm not certain how to do that. sed -n '/ string1 /,/string2/p' infile > outfile & (4 Replies)
Discussion started by: dcfargo
4 Replies

8. Shell Programming and Scripting

Removing empty lines(space) between two lines containing strings

Hi, Please provide shell script to Remove empty lines(space) between two lines containing strings in a file. Input File : A1/EXT "BAP_BSC6/07B/00" 844 090602 1605 RXOCF-465 PDTR11 1 SITE ON BATTERY A2/EXT... (3 Replies)
Discussion started by: sudhakaryadav
3 Replies

9. Shell Programming and Scripting

select a line that contains the strings

hi i have a file, from the file i need to extract the lines that contains both 17 and Received msg string, i used cat <filename> | grep 17 | grep "Received msg" > <new file> but it is not giving the required o/p please help thanks in advance Satya (3 Replies)
Discussion started by: Satyak
3 Replies

10. Shell Programming and Scripting

Find lines with space between strings

Hello all, I am having trouble with setting up a regular expression used with egrep. My script reads an input file a line at a time. I would like the egrep command to search for the following pattern: server name at the beginning of the line, then one or more spaces, and then a pound sign. ... (5 Replies)
Discussion started by: Galt
5 Replies
Login or Register to Ask a Question