March 2002
Beginner
504 pages
10h 47m
English
| 1: | Write a function called getCharCount that prints the number of characters in a file. Use wc to obtain the character count. Linux, FreeBSD, and SunOS (not Solaris), use the -c option for wc, whereas other versions of UNIX use the -m option. Feel free to use the function getOSName. |
| A1: | A possible implementation is
getCharCount() {
case `getOSName` in
bsd|sunos|linux)
WCOPT="-c" ;;
*)
WCOPT="-m" ;;
esac
wc $WCOPT $@
}
|
Read now
Unlock full access