Hacker News new | past | comments | ask | show | jobs | submit login

Of all the things awk can do, I will never understand the popularity of echoing an argument.

The same thing in bash would be:

  $ arg1 () { echo $1; }
  $ arg1 one two three
  one
Splitting fields is easy with cut:

  $ echo one two three | cut -f 1 -d " "
  one
Normally you just want to stuff it into a variable in which case read is much easier:

  $ read arg1 arg2 arg3 < <(echo one two three)
  $ echo arg1
  one
Symbolic names are normally much easier to read than numeric positions.

That last example looks a bit weird with <() instead of a pipe, but that's just because the right hand side of a pipe is a separate shell so setting variables in it is a bit useless. It's nothing specific to read.




Consider applying for YC's Fall 2025 batch! Applications are open till Aug 4

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

Search: