Docsity

Unix & perl question, Exams of Computer Science

Toggle sidebar
bg1
1.Devices in unix are
a)Files
b)Directories
c)Blocks
d)none
2.statement starting of bourne shell
a)#!/bin/dir/ksh
b)#!/bin/dir/sh
c)#!/bin/dir/csh
d)none
3.print reverse (cat on the wall)
a)wall on the cat
b)llaw ehe no tac
c)wallonthecat
d)llawehtnotac
4.which command is used to print the files
a)grep –n
b)grep –b
c)grep –v
d)grep –V
5.>command
a)input
b)output
c)both
d)none
6. O/P of the foll:
$V = HELLO WORLD
$echo $V
a) HELLO WORLD
b) HELLO
c) echo $V
d) echo HELLO WORLD
7.print ‘X’.5*5
a)X . 25
b) X
c)25
d)5
8.declare a number
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe
pff
pf12
pf13
pf14
pf15
pf16
pf17
pf18
pf19
pf1a
pf1b
pf1c
pf1d

Partial preview of the text

Download Unix & perl question and more Exams Computer Science in PDF only on Docsity!

1.Devices in unix are

a )Files b)Directories c)Blocks d)none

2.statement starting of bourne shell a)#!/bin/dir/ksh

b)#!/bin/dir/sh c)#!/bin/dir/csh d)none

3.print reverse (cat on the wall) a)wall on the cat b)llaw ehe no tac c)wallonthecat d )llawehtnotac

4.which command is used to print the files a)grep –n b)grep –b c)grep –v d)grep –V

5.>command a)input b) output c)both d)none

  1. O/P of the foll: $V = HELLO WORLD $echo $V a) HELLO WORLD b) HELLO c) echo $V d) echo HELLO WORLD

7.print ‘X’.5* a) X. 25 b) X c) d)

8.declare a number

Begin

a:=’XX’ end a)value_error b) invalid_number c)no error d)no_Data_found

  1. Why the symbol ‘#!’ in unix is used a) Documentation b) comment c) to specify text comment etc
  2. single line comment a)@@ b) — c)/* d)&&
  3. In Bourne shell you have to EXPORT the declared environmental variables. a) TRUE (not sure) b) False
  4. $string=~/s+//g……………………………………. a)……one or more spaces into jus a single space b)……zero or one spaces into jus a single space c)……all spaces into jus a single space d)none

13.read only command in perl a) –v b) –x c) –e d)-r

  1. what is the output Print ‘the string is $var’ a)the string is b)the string is $var c)the string is d)none
  2. Some code snippet will this give an error? Read gg

c) none of above d) documentation

  1. which one is not the environment variable? a) Path b) pwd c) read d) random

  2. Which loop assigns itself array variables one by one to its looping variable? a) do b)while c)for d) foreach

  3. which sort option is correct for displaying lower case to upper case strings? a) Sort –r b) Sort –t c) Sort –n d) Sort –f

  4. which one is used to open the file for read access only? a) < b) > answer c) << d) none

  5. $? Is used for a) not found b)? Value

27)option used for file not found in unix. a) e b) f

  1. $name=asdf Print ‘my name is $name’ a) asdf b) my name is $name
  1. Use of grep command-which parameter is used to give the number of lines which does not match – v

30.)Output of last echo in the script -

read a b c echo $a $b echo $c

31.To copy content of one filel to another file cp mv join add

32 .a number b number c as Boolean c = a > b what should be the value of c ( will give the 3rd value as provided at read)

33.declare begin declare var1 as number begin var1 := 10 end. output var1. end.

what will be the output

(false or 0)

34.What will be the output of the following /bin/sh echo "welcome". lkjdsbfkljdbsf cannot recollect

40.how parameter is passed in argument

a) arg <> 10 b) arg > 10 something like that....

41.How to know the working shell in unix?

.e Ps .f echo $shell .g echo $ .h none of the above

42.How to join two lines in Vi editor .i j .j J .k CNTRL + J .l SHIFT + J ANS: J

43How to give write permission to all - $chmod 777

44.$var1=1m1.hdr $echo var1 ( shud be echo $var1 ) what is the output?

ANS 1m1.hdr

45.How to get rid of variable assigned in C shell .m UNSET .n DESET .o DISSET

.p RESET

46.How to create link file in UNIX .q ln -h .r (^) ln -s .s ln –l .t ln –so

47.When exit command is not the part of the shell script , status of exit command shown will be previous command

48.outtput S <<! clear cup 10 10 bold ! What will be the output?

49.Esc’ in vi editor – ANS :- command Mode

50. What is the variable that stores the current working shell( $ shell)

  1. In unix which function is used to read the data. -read. -scanf. -printf.

51)Which function converts all the Lower case to upper case -n -U -o -r

  1. Which is not a valid pre-defined exception. -value_not_found. -value_error. -Zero_Division. -none

  2. What is the datatype of declearing Exception. Ans: Exception.

dbms_output.put_line('Value of i is ' || i); i := i + 1; END LOOP; END; a) (^10) b) 25 c) 50 d) None of the above

  1. In UNIX, what does this command give? $? Do a) $? not found b)? no found c) gives------ if execution of previous shell commands were successful d) (^) none of the above
  2. Join 2 lines j J Ctrl + j Shift + J
  3. Copy 3 lines into buffer a) 3dd b) (^) 3yy c) 3mm d) 3lm
  4. What is the o/p Print ‘the string is $var’ a) the string is b) the string is $var c) (^) error d) I don’t remember
  5. Which construct is for “execute until a condition is satisfied” a) While b) Do Until c) For d) If
  6. Some code snippet consisting of Unget, read gg etc n was asked the o/p a) Error

68 What is the o/p

my @numbers = {‘One’,’Two’,’Three’}; Print splice(@numbers,1,1); One OneTwo OneTwoThree TwoThree

69 Read permission to all files a) chmod 444 b) chmod 777 c) chmod 424 d) chmod 4

read – 444 write – 222 execute – 111

  1. Don’t remember the Question something to do with file copy/append or something a) >> $file b) < $file c) > $file d) << $file
  2. Print “X”. 5* a) X. b) X c) syntax error d) X.
  1. Write permission to all files e) chmod 222 f) chmod 333 g) chmod 341 h) chmod 345

  2. Which key is used to go to next character in vi editor- L

74.cd/ mean in unix------ root directory

75.first line in bourne shell----- #!/bin/sh

b) gives the status of previously made command c) nothing d)

85.To add contents of one file to another what is the command a) cp b) mv c) add d) join

86.what will be the output of the command $ 10 -l wipro.20 (not exact) a) displays 10 lines of the file b) displays 20 lines of the file c) displays the whole file d) no output

87.What will be the output of the following /bin/sh echo "welcome". lkjdsbfkljdbsf cannot recollect some function()... echo "Thanks"

a) 1 b) 0 c) welcome d) Thanks

88 If i want to list all the directories, which command shall i use? a) ls -ltr b)ls -d c)ls -dir d ) ls –l

89.What is unix command for listing directory a. ls -l b. ls -tr c. ls -d d. ls –dir

90.What is unix command for renaming a file a. cp b. mv c. cpio d...

91.output of something like:

$echo "xxxyyyy" > abc.txt $echo "ggghhhh" >> abc.txt $cat abc.txt

  1. what does command $? do? a. $ not found b.? not found c. error d. none of above

93.how parameter is passed in argument a) arg <> 10 b) arg > 10 something like that....

94which one is correct a) pragma exception_init(error msg,-code) b) pragma excep_init(error,-code) like that...

95.How to know the working shell in unix? .u (^) Ps .v echo $shell .w echo $ .x none of the above ANS - echo $

96Which keyword is used along with the variable so that user is not prompted multiple times for input variable .y & .z && .aa # .bb None of the above ANS - &&

97.What will be the output of the last echo of the below script, if the input is given as ONE TWO THREE FOUR FIVE #!bin/ksh Read a b c Echo $a $b Echo $c

! What will be the output?

  1. ‘Esc’ in vi editor – ANS :-command Mode

107 $a = 2; $a = ‘echo 3 * $a + 1 \ bc’; $echo a; .ww 7 .xx 12, .yy 16, .zz None of these

108. command to list the directories .aaa ls –l .bbb (^) ls –tr .ccc ls –d-------------WILL LIST THE CURRENT DIRECTORY .ddd ls -ltr

109.In a Bourne shell to set an environment variable, export is reqd? T /F

110 O/P of the foll: $V = HELLO WORLD $echo $V a) HELLO WORLD b) HELLO c) echo $V d) echo HELLO WORLD

  1. Export is needed to assign an ENV var in Bourne Shell. True/False.
  2. A device is represented as what in UNIX? Ans – File.
  3. echo ‘welcome’ $rtrn = $?; If ($rtrn –ne 0 ) then Echo ‘problem’ Else echo ‘success’ What is the output?
  4. echo * equivalent to - a. ls (answer) b. ls -ltr c. ls -d d. ls -a
  1. Which command will re-direct output of prior command to standard input of another

.1 who || sort .2 who | sort .3 who >> sort .4 (^) who > sort

116.Output of $ v=ls $ echo $v .5 list all files. .6 ls. .7 echo. .8 none.

  1. Sort filter folds lower case char to upper case
  1. sort –r 2) sort –f 3) sort –n 4) sort –t
  1. In unix which function is used to read the data. -read. -scanf. -printf.

119)Which function converts all the Lower case to upper case -n -f -U -r

  1. vi -24 file1; -will open file1 and file 24. -will open file1 & cursor at line 24.

-show error.

  1. $van='Roy'; #san='$van' print 'How are u #san' What will be the output of above exection. 'How are u #san'

  2. lib file is stored at which location in pearl. Ans : /etc.

g) For h) If

  1. Some code snippet consisting of Unget, read gg etc n was asked the o/p a) Error
  2. What is the o/p my @numbers = {‘One’,’Two’,’Three’}; Print splice(@numbers,1,1); One OneTwo OneTwoThree TwoThree
  3. Read permission to all files i) chmod 444 j) chmod 777 k) chmod 424 l) chmod 4
  4. Don’t remember the Question something to do with file copy/append or something e) >> $file f) < $file g) (^) > $file h) << $file

143Print “X”. 5* e) X. f) X g) syntax error h) X.

144Why the symbol ‘#!’ in unix is used )a Documentation b) comment c) to specify text comment etc (used to reflect the current shell or script to be used)

145._________ is primarily used to trace and made only in the read format (don’t remember exactly) a) TKPROF (not sure) b)v$TKPROF c)TRACE d) None

  1. In Bourne shell you have to EXPORT the declared environmental variables. a) TRUE b) False
  2. $string=~/s+//g……………………………………. a)……one or more spaces into jus a single space b)……zero or one spaces into jus a single space c)……all spaces into jus a single space d) None
  3. Read only command a) –v b) –x c) –e d)-r
  4. What is the output? Print ‘the string is $var’ a) The string is b) The string is $var c) The string is d) None
  5. Some code snippet will this give an error? Read gg Readonly gg Unset gg Read gg c) yes d) no
  6. $fred =”pay” $fredday=”workday” $bred=”it’s a $fredday” Print $bred. a)payday b) Its a workday c) $bred d) None

152What is o/p of following code? #!/usr/bin/ksh IFS=’ui’ Ctr= Teststring=”something” For file in $teststring Do