. Write a shell function called octal that converts octal numbers given as command-line arguments to decimal numbers and prints them out, one per line

$ octal 10 11 12
8
9
10
(Korn shell users, remember that if you assign a decimal number to a variable when it's declared – for example, typeset –i d=10#0 – assignments to this variable from other bases are automatically converted to decimal.)


This one's easier than it seems. Here's a simple solution:
#!/bin/sh

# octal - given octal values, display as decimal values

for octalnum
do
(( i = 8#$octalnum ))
echo $i
done

exit 0

Computer Science & Information Technology

You might also like to view...

Match the following commands to the corresponding outputs. Place the letter that indicates your answer on the line in front of each command.

- Your have the following two variables defined: XYZ=HELLO EMPTY= _____ 1. echo $XYZ _____ 2. echo $EMPTY _____ 3. echo ${XYZ: "BYE"} _____ 4. echo ${EMPTY: "BYE"} _____ 5. echo ${XYZ: + "BYE"} _____ 6. echo ${EMPTY: + "BYE"} _____ 7. echo ${XYZ: = "BYE"} _____ 8. echo ${EMPTY: = "BYE"} _____ 9. echo ${XYZ: ? "BYE"} _____ 10. echo ${XYZ: ? "BYE"} a: HELLO b: BYE c: Nothing is displayed

Computer Science & Information Technology

In Windows Media Player, the terms picture and photograph are different types of files

Indicate whether the statement is true or false

Computer Science & Information Technology

Case-Based Critical Thinking QuestionsCase 3-1Chris has inherited the management of some highly disorganized projects from her predecessor. One of its hallmarks is that the projects included a lot of constraints that have proven unnecessary, and which have complicated the reporting on the projects and the accurate assessment of where things stand. Because you were privy to a lot of the background about the projects, Chris has asked you to help her sort it all out.Chris zeroes in on a particular task of writing the marketing copy, which has a Finish date. Keeping in mind that the overall project is scheduled from a Start date of 2/11/2009, what was the constraint type automatically applied to the writing of the marketing copy, if the copy is scheduled to be written on or after the date

specified? A. Finish No Later Than B. Finish No Earlier Than C. Must Finish On D. Must Start On

Computer Science & Information Technology

CASE tools are used to compile programs to test for logic errors.

Answer the following statement true (T) or false (F)

Computer Science & Information Technology