Proces the content of /etc/passwd file field by field

Here IFS sets the “internal field delimiter” to “:”, but only inside the while loop. You must NOT reset it to the original value.

while IFS=: read name passwd uid gid fullname ignore
  echo "$name ($fullname)"
done < ${TMP}   # I/O redirection.

Do some actions for secrtain files:

Comparison with shell

If you read “man test” you’ll note that the “=” comparison operator is for strings, while “-eq” is used for numerical comparisons.

If you want to get really fancy, you can also write your code as (not tested, so try at your own risk):

[ $choice -eq 1 -a $choice1 -eq 0 ] && while [ $target -ne 2 ] ; do


  2. Advanced Bash-Scripting Guide (also in PS, PDF, HTML). URL:
Some ‘bash’ Magic
Tagged on:     

Leave a Reply