Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.
#!/bin/bash
username=$(sqlite3 db.sl3 "select user from main";)
yad --list --column="#" "$username" --height 200

I want to display the usernames of my db in a list and then select one of theme.
The problem with the code above is that the username "a b c" are treated as an unique username.
How can i split them into more username?

share|improve this question

2 Answers 2

up vote 2 down vote accepted

If your user names don't contain any spaces or special characters (*?\[), you need just remove " and it will work ok:

yad --list --column="#" $username --height 200
share|improve this answer
    
Thanks a lot :D –  polslinux May 18 '12 at 10:24
1  
Excepting for usernames which contain spaces. –  manatwork May 18 '12 at 10:26

In such cases is advisable to store the data in an array. With version 4.0 or never the simplest is to use mapfile to populate it:

#!/bin/bash
mapfile username < <(sqlite3 db.sl3 "select user from main")
yad --list --column="#" "${username[@]}" --height 200
share|improve this answer
    
I must read the newest bash v4 function :) thanks!! –  polslinux May 18 '12 at 10:30

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.