Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Please note that 'each' is fundamentally different from 'xargs'.

  echo 1 2 3 | each "rm {}"
is the same as

  rm 1
  rm 2
  rm 3
while

  echo 1 2 3 | xargs rm
is the same as

  rm 1 2 3
I would rather say that 'each' replaces (certain uses of) 'for':

  for i in 1 2 3; do rm $i; done


It's equivalent to xargs -I {} rm {}

       -I replace-str
              Replace occurrences of replace-str in the initial-arguments
              with names read from standard input.  Also, unquoted blanks
              do not terminate input items; instead the separator is the
              newline character.  Implies -x and -L 1.




Consider applying for YC's Summer 2026 batch! Applications are open till May 4

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: