Advertisement

02.17.2008 at 06:28AM PST, ID: 23169583
[x]
Attachment Details

How do i deal with spaces in file names?

Asked by couldntcarebear in Bourne-Again Shell (bash), Shell Scripting

Tags: bash

I'm trying to write a shell script (bash) which simply takes a list of directories (using ls) and passes them to a kdialog for a user to choose from.

What i have so far works fine for directories without spaces in but shows both components as separate entries when a space is involved and is passed

e.g. the following directories
nospace1
nospace2
one space

comes out as:
nospace1
nospace2
one
space

in the kdialog combobox

How do i get spaces to work in this instance?

Cheers




Start Free Trial
1:
2:
3:
dest_path="/path/to/directory/"
choose_target=`ls $dest_path`
chosen_dir=`kdialog --combobox "Select Target Directory" $choose_target`
[+][-]02.17.2008 at 06:37AM PST, ID: 20914114

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]02.17.2008 at 06:44AM PST, ID: 20914140

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]02.17.2008 at 06:47AM PST, ID: 20914150

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]02.17.2008 at 06:48AM PST, ID: 20914157

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]02.17.2008 at 06:54AM PST, ID: 20914182

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]02.17.2008 at 06:57AM PST, ID: 20914192

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]02.17.2008 at 07:08AM PST, ID: 20914233

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]02.17.2008 at 07:38AM PST, ID: 20914317

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]02.17.2008 at 08:01AM PST, ID: 20914380

View this solution now by starting your 7-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zones: Bourne-Again Shell (bash), Shell Scripting
Tags: bash
Sign Up Now!
Solution Provided By: florin_ganea
Participating Experts: 3
Solution Grade: A
 
 
[+][-]02.17.2008 at 08:27AM PST, ID: 20914473

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]02.17.2008 at 08:39AM PST, ID: 20914522

Assisted solutions are selected by the member who asked the question as a comment that contributed to their question's solution.

Start your 7-day free trial to view this Assisted Solution or ask the Experts your question.

 
[+][-]02.17.2008 at 08:54AM PST, ID: 20914572

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
 
Loading Advertisement...
20080716-EE-VQP-32 / EE_QW_2_20070628