Hour 5

1: Which file descriptors are associated with STDOUT, STDERR and STDIN?
A1: The file descriptors associated with STDOUT, STDERR, and STDIN are 0, 2, and 1 respectively.
2: Use printf to convert the numbers 16, 255, and 65535 into hexadecimal and octal.
A2: You can use the following printf statements:
printf "0%o 0%o 0%o \n" 16 255 65535
printf "0x%x 0x%x 0x%x\n" 16 255 65535
3: Given the following script:
exec 4>out.txt
exec 5>&4
exec 1>&5
date

Where does the output from date end up?

A3: The output ends up in the file out.txt.

Get Sams Teach Yourself Shell Programming in 24 Hours, Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.