TCS Xplore Unix All Module Answers 2022

TCS Xplore Unix All Module Answers 2022

Below are the answers of TCS Xplore Unix for all modules. Answers are highlighted in yellow color





Question: What is the syntax to combine the content of two files(file1, file2) into another file (newfilename)?
a) cat file1 file2>newfilename
b) cat file1 file2>>newfilename
c) cat file1 file2<newfilename
d) cat file1 file2<<newfilename


Question: Example.txt file contains the following text:

Java Programming Language.
Java and Python are programming languages.
Python Programming language.

What is the output generated by the below command.
$ grep -v Java Example.txt
a) Java and Python are programming languages. Python Programming language.
b) Java Programming Language.
    Java and Python are programming languages.
c) Python Programming language.
d) Java Programming Language. Python Programming language.


Question: When we are deleting the folder and when we are not sure whether the folder is having files or not in it? Then which of the below command is right command to apply, which deletes only the folder which are empty?
a) rm
b) rmdir
c) rm -rf
d) rmdir -i


Question: In shell script if we write the below statement, what does the statement refers to?
if [-r $2 ]
then 
a) The second argument supplied from command line Argument is existing or not 
b) Verifies, whether the user is having the read permission on the file ( whose name supplied from command line Argument, as second ) or not
c) The file supplied from command line argument is existing or not
d) The column is existing or not


Question grep "Tata.*Services$"*
what would be the output of the above command?
a) It will display the filename and the pattern ("Tata Consultancy Sevices Limited"), if the pattern is found in any file
b) It will display the filename and the pattern ("Tata Motors Limited"), if the pattern s found in any file
c) It will display the filename and the lines ending with the pattern("Tata Consultancy Services") in the file
d) It will display the filename and the lines ending with the pattern ("Tata Capital Services") in the file



Question: Which symbol will be used with grep command to match the pattern pat at the beginning of a line?
a) ^pat
b) pat^
c) $pat
d) pat$


Question: the user u123456 logged in and performed the following sequence of command. User's home directory is /home/u123456. What will be he output of the last command?
a) /home/u12345/project/module1
b) project/module1
c) ~/project/module1
d) /usr/u123456/peoject/module1


Question: Which code will correctly calculate the newsal based on the years mentioned Input file is as below
NameOfEmployee-age-YearOfJoining. 
The Shell takes 2 inputs-file name and Name of Employee. Delimiter used in the input file is  - 
a) #!/bin/sh
x = $1
y=$2
if[-f $1]
then 
z = $(grep $2 $1|cut -d '-' -f3)
echo $z
case "$z" in 
"1990") newsal = 'expr $(grep $2 $1|cut - d "|" -f5) + 200'
"2000") newsal = 'expr $(grep $2 $1|cut - d "|" -f5) + 1000'
"2005") newsal = 'expr $(grep $2 $1|cut - d "|" -f5) + 500'
;;
easc 
fi

b) #!/bin/sh
x = $1
y=$2
if[-f $1]
then 
z = $(grep $2 $1|cut -d '-' -f3)
echo $z
case "$z" in 
"1990") newsal = 'expr $(grep $2 $1|cut - d "|" -f5) + 2000'
"2000") newsal = 'expr$(grep $2 $1|cut - d "|" -f5) + 1000'
"2005") newsal = 'expr$(grep $2 $1|cut - d "|" -f5) + 500'
;;
easc 
fi

c) #!/bin/sh
x = $1
y=$2
if[-f $1]
then 
z = $(grep $2 $1|cut -d '-' -f3)
echo $z
case "$z" in 
"1990") newsal = 'expr $(grep $2 $1|cut - d "|" -f5) + 2000'
"2000") newsal = 'expr$(grep $2 $1|cut - d "|" -f5) + 10'
"2005") newsal = 'expr$(grep $2 $1|cut - d "|" -f5) + 500'
;;
easc 
fi

d) #!/bin/sh
x = $1
y=$2
if[-f $1]
then 
z = $(grep $2 $1|cut -d '-' -f3)
echo $z
case "$z" in 
"1990") newsal = 'expr $(grep $2 $1|cut - d "|" -f5) + 2000'
"2000") newsal = 'expr$(grep $2 $1|cut - d "|" -f5) + 1000'
"2005") newsal = 'expr$(grep $2 $1|cut - d "|" -f5) + 50'
;;
easc 
fi




Question: Which Command will delete the lines containing the pattern 'this' from the file?
a) delete -f this file
b) SED /this'/d file 
c) Sed /'this'/d file
d) sed /this/d file



Question: Assuming the files fileA, fileB, fileAB, fileBC and fileABC, exist in a directory testDir, which files will be listed if we use the following command
$ls testDir|grep file[AB]?
a) file A
b) file B
c) file ABC
d) file BC