[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Help-bash] Commands run via xargs and bash returns different result
From: |
dethrophes |
Subject: |
Re: [Help-bash] Commands run via xargs and bash returns different results |
Date: |
Tue, 04 Feb 2014 14:58:31 +0100 |
I think you meant.
while IFS= read -r cline; do
Sent from my BlackBerry 10 smartphone.
Original Message
From: Greg Wooledge
Sent: Dienstag, 4. Februar 2014 14:20
To: Richard Taubo
Cc: address@hidden
Subject: Re: [Help-bash] Commands run via xargs and bash returns different
results
On Mon, Feb 03, 2014 at 10:52:32PM +0100, Richard Taubo wrote:
> By setting: my_path="{}? I was trying receive each of the paths
> handed over from mdfind via xargs, and then use this variable to
> create html list based output, e.g something like:
> "<li>$my_path</li>?
echo "<ul>"
while read -r path; do
echo "<li>$path</li>"
done < <(mdfind -whatever)
echo "</ul>"
And even that's fancier than you may need for this particular task.
(Writing it with the process substitution forces the loop to run in
the current shell, so that you can set variables inside the loop and
have them survive. The pipeline alternative does not permit that.)
xargs is obtuse, hard to use, and fraught with peril.
imadev:~$ echo "don't" | xargs echo
xargs: missing quote?: dont
A shell loop is far more flexible, and doesn't break on inputs that
contain spaces and quotes.