Explore topic-wise InterviewSolutions in .

This section includes InterviewSolutions, each offering curated multiple-choice questions to sharpen your knowledge and support exam preparation. Choose a topic below to get started.

1.

To replace | with ~, which one of the following commands will be used?(a) tr ‘|\’‘~-‘(b) tr ‘|\’‘~-‘ > emp.lst(c) tr |~ emp.lst(d) !I got this question in an interview for job.My question comes from Unique and tr Command in division Simple Filters of Unix

Answer»

The correct answer is (b) tr ‘|\’‘~-‘ > emp.lst

For explanation I would SAY: The translate (tr) FILTER is used for manipulating individual characters in a LINE. It replaces the first character in the first EXPRESSION with the first character in the second expression.

2.

Which option is used with tr command for deleting characters?(a) -d(b) -c(c) -n(d) -aThis question was addressed to me by my school principal while I was bunking the class.I need to ask this question from Unique and tr Command in division Simple Filters of Unix

Answer»

Right OPTION is (a) -d

For EXPLANATION I would say: By using tr command we can delete the characters from a FILE. To perform this operation, we’ve to use -d option. For EXAMPLE,

3.

______ option is used for compressing multiple consecutive characters.(a) -d(b) -c(c) -n(d) -sThe question was posed to me in a job interview.My doubt stems from Unique and tr Command in section Simple Filters of Unix

Answer»

The correct choice is (d) -s

For EXPLANATION I WOULD SAY: tr command can ALSO remove multiple consecutive characters from a line by using -s option. This will make the line squeeze from multiple consecutive occurrences of a character to a single character. For example, to squeeze multiple contiguous spaces use the following command:

4.

Which command is used for translating characters?(a) sort(b) trans(c) tr(d) pasteThe question was asked during a job interview.I'm obligated to ask this question of Unique and tr Command topic in chapter Simple Filters of Unix

Answer»

The correct choice is (c) tr

For explanation: The TRANSLATE (tr) filter is used for manipulating individual characters in a LINE. USUALLY, tr command translates characters using one or TWO compact EXPRESSIONS. The syntax for using tr command is,

5.

______ option is used for counting frequency of occurrence.(a) -d(b) -c(c) -u(d) -aThe question was posed to me in class test.I want to ask this question from Unique and tr Command topic in division Simple Filters of Unix

Answer»

Correct CHOICE is (B) -C

Easiest explanation: We can use the -c option with UNIQ command to count the FREQUENCY of occurrence of all lines along with the lines. For example,

6.

Which option is used for selecting repeated entries?(a) -d(b) -c(c) -u(d) -aI have been asked this question in my homework.My question is from Unique and tr Command in division Simple Filters of Unix

Answer»

The CORRECT choice is (a) -d

The explanation: The -d option when used with UNIQ COMMAND lets US select only ONE copy of duplicate entries. For example,

7.

Which option is used with uniq command for selecting non-repeated lines?(a) -i(b) -c(c) -u(d) -aI have been asked this question in an interview for internship.My question comes from Unique and tr Command in chapter Simple Filters of Unix

Answer» CORRECT ANSWER is (c) -u

For explanation I would say: To select unique lines, we can use the sort -u command. But uniq also offers an option (-u)which is used for SELECTING non-repeating ENTRIES in a field. For example,
8.

Which command is used for locating repeated and non-repeated lines?(a) sort(b) uniq(c) cut(d) pasteThis question was addressed to me by my college director while I was bunking the class.This key question is from Unique and tr Command in section Simple Filters of Unix

Answer»

The correct choice is (b) uniq

To elaborate: When we concatenate or MERGE files, we can encounter the PROBLEM of duplicate entries creeping in. UNIX offers a special command (uniq) which can be USED to handle these duplicate entries. We can ALSO use the sort -U command for doing the same piece of work.

9.

uniq command requires a sorted file as input.(a) True(b) FalseI had been asked this question during an interview for a job.My question is taken from Unique and tr Command topic in chapter Simple Filters of Unix

Answer»

Correct OPTION is (a) True

Easiest explanation: uniq command is USED for locating REPEATED and non-repeated entries. But the most important requirement for using uniq command is, the FILE should be sorted. For EXAMPLE,

10.

Which option is used with sort command to sort multiple files collectively?(a) -m(b) -n(c) -c(d) -oThe question was asked during an online exam.This interesting question is from Sort Command topic in portion Simple Filters of Unix

Answer»

The CORRECT option is (a) -m

Explanation: When we USE sort command with multiple FILENAMES as ARGUMENTS, it concatenates all of them and sorts them collectively. -m option usually makes the performance to suffer. For example, to sort three FILES, use the following command:

11.

To check whether the file has actually been stored in the default order, we can use ____ option.(a) -n(b) -a(c) -d(d) -cThe question was posed to me in a job interview.I'm obligated to ask this question of Sort Command topic in division Simple Filters of Unix

Answer»

Right choice is (d) -c

The EXPLANATION is: sort command provides an option with the use of which we can check WHETHER the file has actually been STORED in the default order. For EXAMPLE,

12.

Which option is used by the sort command to redirect the output to a specified file?(a) -n(b) -t(c) -o(d) -uThis question was posed to me by my school principal while I was bunking the class.This interesting question is from Sort Command topic in chapter Simple Filters of Unix

Answer»

Correct choice is (c) -o

The EXPLANATION: Even THOUGH we can redirect the output of SORT to a file, we can also use its -o OPTION for SPECIFYING the output file. For example,

13.

_____ option is used with sort command for removing repeated lines.(a) -n(b) -u(c) -t(d) -aI had been asked this question in an online quiz.The question is from Sort Command in portion Simple Filters of Unix

Answer»

Right choice is (b) -u

Best explanation: sort provides an option i.e. -u (unique) which lets us remove REPEATED lines from a FILE. We can use this option with sort COMMAND to find unique occurrences in the file. For example,

14.

The name of the input and output files cannot be same while using sort command.(a) True(b) FalseThis question was addressed to me in examination.This interesting question is from Sort Command in section Simple Filters of Unix

Answer»

The correct choice is (b) False

The best explanation: EVEN THOUGH we can redirect the output of SORT to a file, we can also use its -o OPTION for specifying the output file. And the interesting fact is, the name of the input and output file can be same. For EXAMPLE,

15.

Which option is used when we’ve to sort files containing only numbers?(a) -n(b) -a(c) -d(d) -uThe question was posed to me in exam.My query is from Sort Command topic in chapter Simple Filters of Unix

Answer»

The correct CHOICE is (a) -n

Explanation: When SORT COMMAND acts on a numeral, strange THINGS can happen if a file contains only NUMERALS. So we have to use the -n option with sort command. For example,

16.

The sort order can be reversed using ___ option.(a) -t(b) -k(c) -r(d) -nThis question was addressed to me in an online quiz.The query is from Sort Command topic in section Simple Filters of Unix

Answer»

Right OPTION is (c) -r

Explanation: The sort order can be REVERSED using -r option. For EXAMPLE, the following SEQUENCE REVERSE the order,

17.

Which option is used with sort command to specify the field delimiter?(a) -a(b) -t(c) -k(d) -nI have been asked this question during an internship interview.I need to ask this question from Sort Command in portion Simple Filters of Unix

Answer»

Right answer is (B) -t

Easy EXPLANATION: sort COMMAND uses one or more contiguous spaces as the default field separator but we can specify our own field delimiter using the option -t. For example, to PERFORM SORTING using | as the delimiter, use the following command:

18.

We can perform sorting on secondary key also using sort command.(a) True(b) FalseThis question was addressed to me by my college professor while I was bunking the class.This intriguing question originated from Sort Command topic in chapter Simple Filters of Unix

Answer»

Correct answer is (a) True

To elaborate: We can sort on more than one FIELDS i.e. we can provide a secondary KEY to sort. For example, if the primary key is the THIRD field and the secondary key is the second field, then we have to specify for every -k option, where the sort ENDS. This is done in the FOLLOWING manner:

19.

Which option is used for sorting a file according to primary key?(a) -t(b) -k(c) -n(d) -nThe question was asked in an online quiz.I would like to ask this question from Sort Command topic in portion Simple Filters of Unix

Answer»

Correct choice is (b) -k

Explanation: sort command PROVIDES an option for SORTING file according to our specified field. For this purpose, we have to use -k along with the field NUMBER (based on which we WANT to perform sorting). For example, to perform sorting on second field (name):

20.

We cannot perform sorting on columns using sort command.(a) True(b) FalseThe question was asked in homework.My enquiry is from Sort Command topic in section Simple Filters of Unix

Answer»

Correct answer is (b) False

Explanation: We can also specify a CHARACTER position within a FIELD to the beginning of sort. For example, if we have to sort salary field then we can specify in the form -K m,N where n is the character position in mth field.

21.

Sort command uses ____ as default field delimiter.(a) tab(b) single space(c) double tab(d) one or more continuous spacesThis question was addressed to me in an interview for internship.Asked question is from Sort Command in chapter Simple Filters of Unix

Answer»

Correct option is (d) ONE or more CONTINUOUS spaces

Best EXPLANATION: Unlike CUT and paste command which uses tab as the default field delimiter, SORT command uses one or more contiguous spaces as the default field separator.

22.

____ command is used for sorting a file on specified fields.(a) cut(b) sort(c) pr(d) tailThe question was posed to me in a national level competition.The doubt is from Sort Command topic in portion Simple Filters of Unix

Answer»

Right option is (B) sort

For explanation: SORTING is the ordering of DATA in ascending or descending order. The sort COMMAND is used for ordering a file. Like cut command, sort also identifies fields and perform sorting on specified fields. To sort any file, just provide the name of the file as an argument with sort command.

23.

By default, sort command reorders lines in ASCII collating sequence.(a) True(b) FalseI had been asked this question by my college professor while I was bunking the class.I'd like to ask this question from Sort Command topic in portion Simple Filters of Unix

Answer»

Correct CHOICE is (a) True

Explanation: By default, sort reorders lines in ASCII collating sequence i.e. whitespaces first, then NUMERALS, uppercase LETTERS and at LAST lowercase letters. But we can change this default sorting sequence using a certain sequence.

24.

Which option is used with paste command for joining lines?(a) -s(b) -c(c) -a(d) -eI have been asked this question in an interview.This intriguing question originated from Filtering Commands topic in portion Simple Filters of Unix

Answer»

The correct answer is (a) -s

For explanation I would SAY: The -s option joins the LINE in the same way the vi editor’s J does. Using this option on a file containing MULTIPLE lines will JOIN all of these lines into a single one.

25.

_____ option is used with paste command if we want to specify our own delimiter.(a) -d(b) -c(c) -a(d) -eThe question was asked during a job interview.My question is from Filtering Commands topic in division Simple Filters of Unix

Answer»

The correct option is (a) -d

The explanation: Whatever we’ve cut USING cut command can be pasted BACK using PASTE command. paste command also uses tab as the default field DELIMITER but we can use our own field delimiter using -d option with paste command. For example,

26.

paste command uses space as the default field delimiter.(a) True(b) FalseThe question was posed to me in exam.My enquiry is from Filtering Commands topic in division Simple Filters of Unix

Answer»

Right option is (b) False

The EXPLANATION is: Like CUT command paste command ALSO USES tab as the DEFAULT field delimiter but we can use our own field delimiter using -d option with paste command.

27.

Whatever we have cut using cut command can be pasted back using paste command but vertically.(a) True(b) FalseThis question was posed to me during an internship interview.This key question is from Filtering Commands in section Simple Filters of Unix

Answer»

Correct choice is (a) True

Easy explanation: Whatever we’ve CUT using cut command can be pasted back using paste command. This command is useful when we want to VIEW files side by side by pasting them together. But this command PASTES vertically RATHER than HORIZONTALLY.

28.

Which command is used for pasting files?(a) cut(b) paste(c) tail(d) headThe question was posed to me during an interview.I would like to ask this question from Filtering Commands topic in portion Simple Filters of Unix

Answer»

Right ANSWER is (b) paste

To explain: WHATEVER we’ve cut using cut command can be pasted BACK using paste command. This command is USEFUL when we want to VIEW files side by side by pasting them together. For example,

29.

Which one of the following commands is incorrect?(a) $ cut -d “|”-f1,4emp.lst(b) $ cut -c -3 emp.lst(c) $ tail -c 511 foo(d) $ tail -c fooThe question was asked in an online interview.This key question is from Filtering Commands in portion Simple Filters of Unix

Answer» RIGHT choice is (d) $ tail -c foo

For explanation I WOULD say: tail(1) COMMAND is used for extracting bytes instead of lines while cut(1) command is used for extracting columns and fields. But if we are using tail(1) command, we have to SPECIFY an integer value after the -c option, otherwise, the command will fail.
30.

We have to specify whether we want to cut fields or columns while using cut command.(a) True(b) FalseThis question was addressed to me by my college director while I was bunking the class.This interesting question is from Filtering Commands topic in portion Simple Filters of Unix

Answer»

Right CHOICE is (a) True

To elaborate: Before using cut command, we have to keep in mind that it is necessary to specify that whether we want to cut fields or COLUMNS. This can be specified using -F and -c OPTION respectively.

31.

Which option is used with the cut command for cutting field base on the value of our specified delimiter?(a) -a(b) -f(c) -d(d) -eI have been asked this question during an interview.I need to ask this question from Filtering Commands in chapter Simple Filters of Unix

Answer»

The correct answer is (c) -d

To explain: By DEFAULT, the CUT command uses tab as the default delimiter but we can specify our own delimiter using -d OPTION. For example,

32.

What is the default delimiter used by the cut command for cutting fields?(a) space(b) tab(c) double tab(d) underscoreI have been asked this question in final exam.My doubt is from Filtering Commands topic in division Simple Filters of Unix

Answer»

The correct answer is (b) tab

The explanation is: To EXTRACT USEFUL data from a file, we use the cut command to cut FIELDS rather than columns. The cut command uses tab as the DEFAULT delimiter to cut fields.

33.

____ option is used with the cut command for cutting fields.(a) -c(b) -n(c) -f(d) -aThe question was asked in class test.Question is from Filtering Commands topic in chapter Simple Filters of Unix

Answer»

Right choice is (c) -f

For EXPLANATION: Sometimes we need to extract specific fields from a FILE instead of columns. For this purpose, -f option is used with cut command followed by an integer number REPRESENTING the FIELD. For example,

34.

The expressioncut -c -3 emp.lst will cut columns number _____(a) 3(b) 1(c) 1-3(d) 0I have been asked this question in a national level competition.My question is from Filtering Commands topic in division Simple Filters of Unix

Answer»

The correct choice is (c) 1-3

Best explanation: cut command is used for cutting specific columns. Cut command uses a SPECIAL feature for selecting a column from the beginning and up to END of a line. For EXAMPLE,

35.

To extract specific columns from a file, ____ command is used.(a) tail(b) head(c) pr(d) cutThis question was posed to me in final exam.Asked question is from Filtering Commands in section Simple Filters of Unix

Answer»

Correct answer is (d) cut

The explanation: To extract SPECIFIC columns from a file, we can use cut command FOLLOWED by -c option and list of COLUMN NUMBERS, delimited by a comma. For example,

36.

Which option is used with the tail command for extracting bytes instead of lines?(a) -f(b) -n(c) -c(d) -aThe question was posed to me in an international level competition.Enquiry is from Filtering Commands in chapter Simple Filters of Unix

Answer»

Correct answer is (c) -c

The explanation is: tail command supports the -c option followed by a positive integer or just an integer depending on WHETHER the EXTRACTION is performed RELATIVE to the beginning or END of the file. For example,

37.

Which of the following command is incorrect?(a) pr dept.lst(b) head -n 5 emp.lst(c) tail -o+5 emp.lst(d) tail -3 emp.lstThis question was addressed to me in homework.My question is from Filtering Commands topic in portion Simple Filters of Unix

Answer»

The correct choice is (c) tail -o+5 emp.lst

Best EXPLANATION: The FIRST COMMAND will PREPARE a file for printing by adding header, footers and formatted text. The command head -N 5 emp.lst will display the first 5 lines of emp.lst while the command tail -3 emp.lst will display the last 3 lines of emp.ls

38.

Which symbol is used with the tail command to print the file from the selected line?(a) +(b) –(c) %%(d) ^I had been asked this question in my homework.This intriguing question originated from Filtering Commands in chapter Simple Filters of Unix

Answer»

Correct choice is (a) +

The best explanation: We can also address LINES from the beginning instead of the end. The +count OPTION allows US to do that, where count represents the line number from where the selection should BEGIN. For example,

39.

We can also use -n option with tail command.(a) True(b) FalseI had been asked this question during an interview.I want to ask this question from Filtering Commands in division Simple Filters of Unix

Answer»

Correct choice is (a) True

Best explanation: Alike head command we can ALSO USE the -n option with the TAIL command to specify the line COUNT to be DISPLAYED from the end of the file. For example,

40.

___ command is used for displaying the end of the file.(a) head(b) tail(c) lp(d) prThe question was posed to me during an interview for a job.I would like to ask this question from Filtering Commands in section Simple Filters of Unix

Answer»

Right answer is (b) tail

To explain I would say: Complementing the HEAD COMMAND, the tail command is used to display the END of the file. It provides an additional feature of addressing lines. By default, it DISPLAYS the last ten lines of the file.

41.

Which option is used with the head command to specify line count to display?(a) -a(b) -h(c) -n(d) -oI got this question in quiz.The above asked question is from Filtering Commands topic in chapter Simple Filters of Unix

Answer» RIGHT CHOICE is (C) -n

The explanation: We can use the -n OPTION with the head command to specify a LINE count and display a specific number of lines of the file. -n option is followed by an integer value which donates the number of lines to be displayed. For example,
42.

By default, how many lines are displayed using the head command?(a) 5(b) 10(c) 4(d) 20This question was posed to me in an international level competition.Query is from Filtering Commands in portion Simple Filters of Unix

Answer»

The CORRECT option is (b) 10

The best explanation: The head command, as the name suggests DISPLAYS the top of the file. When this command is USED WITHOUT any option, it displays the first ten lines of the file.

43.

Which command is used for displaying the beginning of a file?(a) pr(b) head(c) begin(d) lpThe question was posed to me by my college director while I was bunking the class.Query is from Filtering Commands topic in division Simple Filters of Unix

Answer»

The correct choice is (b) HEAD

The explanation: The head command is USED for displaying the top of the file. As the name SUGGESTS, it DISPLAYS the beginning of the file which is specified as an argument to the command. For example,

44.

___ operator is used with pr command to start printing from a specific page.(a) –(b) #(c) +(d) &I got this question during an interview.Origin of the question is Filtering Commands in division Simple Filters of Unix

Answer»

The correct option is (c) +

Best EXPLANATION: There’s an option available with PR command which lets the user to PRINT from a specific page number. This FUNCTION is performed by prefixing a + with the page number. For example, to print from page number 5, use the following command:

45.

Which option is used with pr command to display output along with line numbers?(a) -d(b) -n(c) -o n(d) -tI have been asked this question at a job interview.This intriguing question originated from Filtering Commands topic in division Simple Filters of Unix

Answer»

Right option is (b) -n

Easiest EXPLANATION: pr command offers MANY OPTIONS which are USED for producing the output in just the format we need. For example,

-ddouble spaces input

-nnumbers lines, helps in debugging code

-o noffsets lines by n spaces, INCREASES left margin of the page

46.

-h option is used with pr command to add a header of our choice.(a) True(b) FalseI got this question at a job interview.Question is from Filtering Commands in portion Simple Filters of Unix

Answer»

The correct choice is (a) True

To explain I WOULD SAY: If we are not using the -t option with PR command then we can use the -H option to ADD a header of our choice. This option is followed by the header string. For example,

47.

Which option is used with pr command to suppress the header and footers?(a) -p(b) -k(c) -t(d) -nThis question was addressed to me by my college director while I was bunking the class.This intriguing question originated from Filtering Commands topic in chapter Simple Filters of Unix

Answer»

Correct answer is (C) -t

The explanation is: We can use the -t option with PR COMMAND if we want to suppress the headers and associated which are displayed with the output of pr command. For EXAMPLE,

48.

Which option is used with pr command for printing multi-columnar output?(a) -p(b) -k(c) -d(d) -prThe question was asked in an interview.My question is from Filtering Commands in section Simple Filters of Unix

Answer»

The correct CHOICE is (b) -k

The best explanation: -k option is USED with pr command (where k is an INTEGER) for printing in k columns. For example, if a file contains a SERIES of 12 numbers then we can divide the output into 3 columns in this way:

49.

pr command adds ____ lines of margin at the top and bottom.(a) 5(b) 4(c) 2(d) 1This question was posed to me in quiz.The origin of the question is Filtering Commands topic in chapter Simple Filters of Unix

Answer»

Right choice is (a) 5

The explanation is: pr command is used for PREPARING a file for printing by adding suitable headers, FOOTERS and formatted text. It ADDS five lines of margin at the top and five at the bottom. The header shows the date and time of last MODIFICATION of the file along with filename and page number.

50.

Which command is used for preparing a file for printing?(a) cd(b) cat(c) print(d) prI had been asked this question in an internship interview.I'd like to ask this question from Filtering Commands in division Simple Filters of Unix

Answer» CORRECT OPTION is (d) PR

To explain I would say: The pr COMMAND is used for PREPARING a file by adding suitable headers, footers and formatted text. This command is used with a filename as an argument. For example,