I would like to redirect the output of a command to input of mapfile. I'm doing this and it's working:

xls2csv -x $files -W -q | sed '/^$/d' | grep -v '^The' > lista.txt
mapfile -t titulos < lista.txt

I'm trying to use just one command to achieve this. But none of them are working.

xls2csv -x $files -W -q | sed '/^$/d' | grep -v '^The' > mapfile -t titulos
xls2csv -x $files -W -q | sed '/^$/d' | grep -v '^The' | mapfile -t titulos
mapfile -t titulos < <( xls2csv -x $files -W -q | sed '/^$/d' | grep -v '^The' )
  • 4
    The first creates a file called mapfile, the second loses the variable to a subshell (via the pipe); the third looks reasonable to me, though – Jeff Schaller Oct 23 '16 at 14:20
  • @JeffSchaller the third one gives the error "/dev/fd/62: No such file or directory" – marlindo71 Oct 23 '16 at 14:33
  • 1
    Try to export files before execute <(). Secondary you can avoid sed -q | grep -ve '^The' -e '^$' ) – Costas Oct 23 '16 at 15:35

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Browse other questions tagged or ask your own question.