Unix - Filters and Commands

11:  

 Which of the following string functions can be used to find the last occurrence of a given character in a given string?

A.

strncmp

B.

strncpy

C.

strchr

D.

None of the above

 
 

Option: C

Explanation :

strrchr( ) is the correct function. It returns a pointer to the last occurrence of the character specified as argument.

Click on Discuss to view users comments.

priya said: (5:16pm on Thursday 20th March 2014)
strchr is used to find the first occurance of the charcter so the option given is wrong
F. Shaikh said: (1:58am on Wednesday 25th October 2017)
the ans for the question is strrchr() which s not present in the options so the answer should be none of these of the given question.

Write your comments here:



12:  

Consider the program main ( )
{
printf("He arose a victor from\n");
system ("date") ;
printf("the dark domain");
}
                                          If a.out is the executable code corresponding to the above source code, then the command a.out > out f

A. Redirects the output of date to file out f
B. Displays the output of date on the screen
C. Prints everything on the screen
D. Prints the two messages on the screen
 
 

Option: A

Explanation :

Click on Discuss to view users comments.

yash said: (8:59am on Wednesday 15th July 2015)
Here output will be redirected to out file only not to f file because out and f are 2 separate things here.

Write your comments here:



13:  

The default permission bits of a file when it is created for the first time, is controlled by

A.

chmod value

B.

fmask value

C.

umask value

D.

none of the above

 
 

Option: C

Explanation :

On Linux and other Unix-like operating systems, new files are created with a default set of permissions. Specifically, a new file's permissions may be restricted in a specific way by applying a permissions "mask" called the umask. The umask command is used to set this mask, or to show you its current value.

               Most applications would not create files with execute permissions set, so they would have a default of 666, which is then modified by the umask.

Click on Discuss to view users comments.

shikha said: (2:25pm on Thursday 9th July 2015)
What is the meaning of umask???how it is working???pls reply soon

Write your comments here:



14:  

 Let x.c be a C source code. The command cc x.c > y

A. is equivalent to the command cc x.c;mv a.out y
B. is equivalent to the command cc -o y x.c
C. serves no purpose
D. None of the above
 
 

Option: C

Explanation :
The redirection symbol ›, puts everything that will otherwise
be displayed in the screen,

to the named file (y here). If x.c is syntactically correct, then the command cc x.c, silently creates a.out,
but what comes to the screen is nothing (other than the next prompt). So, y will be empty.

Click on Discuss to view users comments.

Write your comments here:



15:  

A file x is created with the following contents
echo today is:
date

           If you type x.then

A. It echoes the message. followed by date.
B. It gives the desired output only if the execute permission of file x is set.
C. The desired output can be got by the command sh x. which works even if x has its execute permission not set.
D. Both (b) and (c)
 
 

Option: D

Explanation :
When you create a file using an editor, it will be assigned default permission setting (determined by the umask value). Generally the execute permission will be off. So. to run a shell script, set its execute bit on. However, if you run sh x, x will be executed, even if its execute bit is off.

Click on Discuss to view users comments.

Write your comments here: