dimanche 22 mars 2015

Do I need "| xargs -n 1" to get around xargs' -I side-effect?


I was suprised to discover this:



$ echo 1 2 3 4 5 | xargs -n 1 echo
1
2
3
4
5

$ echo 1 2 3 4 5 | xargs -n 1 -I FOO echo FOO
1 2 3 4 5


That is, using the -I flag has this side effect:



Also, unquoted blanks do not terminate input items; instead the separator is the newline character.



So the workaround I see is:



$ echo 1 2 3 4 5 | xargs -n 1 | xargs -n 1 -I FOO echo FOO
1
2
3
4
5


Is there a better workaround?


My actual command line looks like this:



echo 102DRIFT 103DRIFT 104DRIFT 105DRIFT | xargs -n 1 | xargs -n 1 -I _DIR_ python process.py /SDcard/DCIM/_DIR_/ MyTrace.gpx 10


(Ubuntu Trusty if relevant.)



Aucun commentaire:

Enregistrer un commentaire