bash: Escape multiple parameters that are read from file

I have a file which contains URLs, one in each line. These URLs may contain spaces or other hazardous elements. I want to call a program with these urls, all of them at once.

urls.txt:

ptoto://domain/maybe with spaces & stuff 1
ptoto://domain/maybe with spaces & stuff 2
ptoto://domain/maybe with spaces & stuff 3

I want transform files like this to a call like:

myCommand "ptoto://domain/maybe with spaces & stuff 1" "ptoto://domain/maybe with spaces & stuff 2" "ptoto://domain/maybe with spaces & stuff 3"


Source: bash

Leave a Reply