I can't find a way to using variables inside YAD
I have the following script:
#!/bin/bash
USERS=$(awk '{print $1}' `pwd`/names.txt | sed -e ':a' -e 'N' -e '$!ba' -e 's/\n/!/g')
YAD=$(yad --title="Hello" \
--form \
--field="User:":CB \
'$USERS!New User')
My working file (names.txt
) contains the following:
Ramiro 1234
Dalia 5678
Persona 9012
But that script results in a list with only two options: "$USERS" and "New User", not the contents of names.txt
Note that the correct syntax for a list in YAD is as follows:
YAD=$(yad --title="Hello" \
--form \
--field="User:":CB \
'Ramiro!Dalia!Persona!New User')
You are not allowing the variable expansion ($USERS
) because of the single quotes. Use double quotes.
Replace this:
'$USERS!New User'
With this:
"$USERS!New User"