Question:
Shell scripting: few example Bourne shell scripts executions
1. Will the following script execute without any error?
#!/bin/sh
if [ "$USER" ]
then
echo I am $USER
endif
echo Script completed.
2. Does the following script parse the password file and print it out by the user's "realname" "home directory" "login name"?
#!/bin/sh
OLDIFS=$IFS
IFS=:
cat /etc/passwd | while read f1 f2 f3 f4 f5 f6 f7
do
if [ "$f5" ]
then
IFS=,
set -- $f5
echo "$f1 $1 $f6"
IFS=:
fi
done
IFS=$OLDIFS.