Rewrite the home program from Exercise 5 in Chapter 6 to use IFS to extract the home directory from /etc/passwd. What happens to the program if one of the fields in the file is null, as in

steve:*:203:100::/users/steve:/bin/ksh
Here the fifth field is null (::).


IFS=":"

if [ $# -ne 1 ] ; then
echo "Usage: home account" ; exit 0
fi

while read a b c d e f g
do
if [ "$1" = "$a" ] ; then
echo Home directory for account $a is $f
fi
done < /etc/passwd

Computer Science & Information Technology

You might also like to view...

A(n) ________ is a set of specific, sequential steps that describe in natural language exactly what a computer program must do to complete its task

Fill in the blank(s) with correct word

Computer Science & Information Technology

A ____ is a grid containing the chart data, attached to the bottom of a chart.

A. chart B. data table C. grid box D. picture

Computer Science & Information Technology

During RADIUS authentication, what type of packet includes information such as identification of a specific AP that is sending the packet and the username and password?

A. accounting request B. access request C. verification request D. authentication request

Computer Science & Information Technology

________ is an app that allows you to post to your blog from a smartphone

A) Blogger B) BlogPoster C) BlogMaster D) MasterBlogger

Computer Science & Information Technology