我需要一些关于 YAD 的帮助。所以这里是代码:
contact=$(while read line
do
firstname=$(echo $line | awk 'BEGIN { FS="|" } { print $2 }')
lastname=$(echo $line | awk 'BEGIN { FS="|" } { print $3 }')
num=$(echo $line | awk 'BEGIN { FS="|" } { print $4 }')
birthday=$(echo $line | awk 'BEGIN { FS="|" } { print $5 }')
if [ $firstname != "" -a $lastname != "" ] ; then
echo "$firstname$lastname"
else
if [ $firstname != "" ] ; then
echo "$firstname,"
elif [ $lastname != "" ] ; then
echo "$lastname"
else
echo "$num"
fi
fi
done < "contactlist.txt" )
idlist=$(while read line
do
idnum=$(echo $line | awk 'BEGIN { FS="|" } { print $1}')
echo $idnum
done < "contactlist.txt" )
sortcontact=$(printf "%s\n" $contact | sort)
selected=$(yad --title="Contacts" --width=200 --height=200 --button="DISPLAY:2" --button="ADD:3" --list --separator="" --column="List" $sortcontact --column="ID:NUM" $idlist)
输出:$idlist 和 $sortcontact 都混在一起了。
我想要的是:列 ID 应该只有 $idlist,而列 List 应该只有 $sortcontact。
txt文件:
1|Joanne|Perez|9173046751.000000|Mar 31|
2|Nikko|Real|9065887272.000000|Mar 21|
3|Try|Haha|9000000000.000000|Jan 15|
4|Nikko|Real|9065887272.000000|Jan 21|
5|Paolo|Perez|9212345678.000000|Jan 25|