1
#!/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?

2

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
  • 1
    Excepting for usernames which contain spaces. – manatwork May 18 '12 at 10:26
4

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
  • I must read the newest bash v4 function :) thanks!! – polslinux May 18 '12 at 10:30

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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