$ cat baard.in
/path/to/some space file
/some tabbed/some tabbed file
/path to/genericfile
/path/to/regular.file
/path/to/exciting!/file!
/path/to/(parenthetical)/file.txt
$ cat my_command
#!/bin/sh
printf "my_command: %s\n" "$1"
Como o awk já analisa linhas, você poderia usá-lo para chamar seu comando com cada registro, tomando o cuidado de citar o parâmetro:
$ awk '{system("./my_command '\''" $0 "'\''");}' < baard.in
my_command: /path/to/some space file
my_command: /some tabbed/some tabbed file
my_command: /path to/genericfile
my_command: /path/to/regular.file
my_command: /path/to/exciting!/file!
my_command: /path/to/(parenthetical)/file.txt
O comando awk falha se houver aspas simples na entrada, como, por exemplo:
/books/Hitchhiker's Guide to the Galaxy.epub
Se você tiver o bash disponível, poderá usar:
$ readarray -t paths < baard.in
$ for((i=0;i < ${#paths[*]}; i++)); do ./my_command "${paths[i]}"; done
my_command: /path/to/some space file
my_command: /some tabbed/some tabbed file
my_command: /path to/genericfile
my_command: /path/to/regular.file
my_command: /path/to/exciting!/file!
my_command: /path/to/(parenthetical)/file.txt
my_command: /books/Hitchhiker's Guide to the Galaxy.epub
ou em ksh93 (gorjeta para resposta de Gilles aqui para a implementação manual do readarray):
$ IFS=$'\n'; set -f
$ paths=( $(< baard.in) )
$ unset IFS; set +f
$ for((i=0;i < ${#paths[*]}; i++)) do ./my_command "${paths[i]}"; done
my_command: /path/to/some space file
my_command: /some tabbed/some tabbed file
my_command: /path to/genericfile
my_command: /path/to/regular.file
my_command: /path/to/exciting!/file!
my_command: /path/to/(parenthetical)/file.txt
my_command: /books/Hitchhiker's Guide to the Galaxy.epub