今天同学去honeywell面试 Unix面试题 分享一下 大家做做看。
1. Jane has two identical files, filea.txt and fileb.txt. What message will she get when she types diff filea.txt fileb.txt ?
2. Jack forgot to sort his two files before a merge. Would sort provide an error message when he typed sort -m-o sorted_file.out filea.txt fileb.txt at the command line?
3. A file named filein contains the two amounts 123. and 123.33 The command is typed sort -nro sort.out filein. In sort.out which amount is displayed first, 123. or 123.33 ?
4. Assume filea.c and fileb.c both contain the line #include stdio.h What is the output of the command grep '^include' *.c |uniq ?
5. Write the grep command to display lines from the file text2 that contain a string of characters starting with st, followed by zero or more characters and ending with ing E.G. sting,straining,string,staining
6.This assignment works with a file called survey. From left to right, the columns in the file contain the name of the country, the area (in thousands of square kilometers, the population (in millions) and the continent that the country is located in. The fields are separated by a colon (:) A cat survey follows:
Canada:3852:25:North America
USA:3615:237:North America
Brazil:3286:134:South America
England:94:56:Europe
France:211:55:Europe
Japan:144:120:Asia
Mexico:762:78:North America
China:3705:1032:Asia
India:1267:746:Asia
Write an awk program file named summary.awk that will be run from the command line :
awk -f summary.awk survey
The program file should perform the following actions:
1) In the BEGIN section, headers should be printed as follows
Country Area Pop Continent Status
----------------------------------------------------------------------------------------------
Ensure that headers are aligned with the columns
Both Field Separator and Output Field Separator should be set to colon (:)
(Hint FS=":")
2) Processing section: Compare field #4
If the field is "North America" then field #5's contents should be "Complete"
If the field is "Asia" then field #5's contents should be "In progress"
If the field is "Europe" then field #5's contents should be "Not Started"
If the field is "South America" then field #5's contents should be "N/A"
The printf statement should be:
printf "%-10s %10d %10d %+15s %+12s\n",$1,$2,$3,$4,$5
3) In the END section, use the NR variable and printf to print out the string
"Number of countries survyed = ?
7. Write a Perl program that asks the user to enter two numeric values. Use the strict and warning pragmas.
Store the variables in $x and $y.
If $y is not zero, divide $x by $y and display the result.
If $y is zero display the message "Division by zero is an illegal operation" and exit the program immediately using the die function.
8. Write a Perl CGI script. The script should open a new browser window and display the messages :
For promotion of CGI scripts into cgi-bin, e-mail the Web-Admin
Direct your requests to Rocket.J.Squirrel@Bullwinkle.com
Both lines should be bold face.
Hints:
1) Use the warning pragma.
2) The @ sign in the e-mail address should be escaped ( e.g. \@ ) so that Perl does not evaluate @Bullwinkle.com as an array
3) Ensure your HTML tags are well-formed (e.g. every <BODY> has a corresponding </BODY> )