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: The common used to find the count of only words in a file?
a) wc -w <filename>
b) wc -words <filename>
c) wc <Filename>
d) None of the options

Question: Which command is used to change permission levels of a file or directory?
a) passwd
b) unset
c)return 
d) chmod


Question: What will be the output of below awk script? awk 'BEGIN { s = 0 while (s<55) { print s; ++s}}'
a) Prints the numbers from 0 to 55.
b) Prints the numbers from 0 to 5d.
c) Command will throw a syntax error
d) It will go to an infinite loop 


Question: Given an input file as below 
red, 20
blue, 22
green, 45
yellow, 2
orange, 70

what will be the output of the below shell script and where will it be saved, when it is executed by passing the above file as input

#!/bin/bash

if [ $# -ne 1 ] then
echo "Pass the input file" else
if [ -f $1 ] && [ -e $1 ] then
awk 'BEGIN {FS=","; s=0} { s=s+$2} END {print s}' $1>outsum cut -d, -f1 $1>>outsum
else
echo "file doesn't exists" fi
fi

a) code won't run due to syntax error.
b) Only first filter's output will be saved into outsum file
c) sum of second column of input file and first column of input file will be obtained using the two filters in the shell. Both output will be saved in file named outsum.
d) Only second filter's output will saved into outsum file


Question: Input file filea.txt contains
hi all
hello everyone 
good morning
good afternoon
Which of the common(s) will print the first line of the file?
a) head -1 filea.txt
b) awk 'NR==1' filea.txt
c) sed -n '1p' filea.txt
d) echo $1 filea.txt


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


Question: What will be the output of beolw command?
sort file1 | uniq -u
a) Command has syntax error
b) Finds the unique lines in the file and sort it 
c) Sort the file named file1 and displays the duplicate lines in the file
d) Sort the file named file1 and displays the distinct lines in the file

Question: Which of the following commands will give the length of a longest line in file
a) wc -l <"filename">
b) wc -L
c) wc -c 1


Question: Which command is used to compress a file in UNIX?
a) zip
b) gzip
c) compress
d) comp