Sample Header Ad - 728x90

problematic script: query buku, select via fzf and then print using (again) buku

0 votes
1 answer
79 views
First and foremost, thank you for taking the time to review the question. I have the following script: select an array of IDs from buku's database, and then use buku again to print information using the previously selected ids.
selected_ids=$(buku --print --format 3 | fzf | cut --fields=1) 
&& test="$(buku --print $selected_ids --format 10)"
Problem: the value of test (echo $test) is blank when I select *multiple entries* via fzf. I tried multiple solutions, including piping into tr:
selected_ids=$(buku --print --format 3 | fzf | cut --fields=1 | tr '\n' ' ' | xargs) 
&& test="$(buku --print $selected_ids --format 10)
but to no avail. My intuition suggests the problem is maybe $selected_ids being interpreted as a whole string. Why? Because when I select via fzf only *one entry*, the value of $test contains the selected value. Any suggestions?
Asked by Răzvan Petruescu (101 rep)
Nov 29, 2023, 04:04 PM
Last activity: Nov 29, 2023, 05:12 PM