FUNDAMENTALS OF COMPUTER

COMPUTER PROGRAMMING FUNDAMENTALS

RASPBERRY PI PROJECT IDEAS

Question [CLICK ON ANY CHOICE TO KNOW THE RIGHT ANSWER]
Which command prints a file’s contents without duplicate lines?
A
uniq
B
cat
C
echo
D
print
Explanation: 

Detailed explanation-1: -To prints only uniq ue lines of a file, we use the-u or –unique option with the uniq command as shown below. $ uniq –u text. txt Print only unique lines. To check more information about the uniq command, we use the–help option with the uniq command in the Linux operating system as shown below.

Detailed explanation-2: -The ‘-u’ option is used to display only the unique lines ( which are not repeated). It will only display the lines that occur only once and write the result to standard output.

Detailed explanation-3: -The uniq command deletes repeated lines in a file. The uniq command reads either standard input or a file specified by the InFile parameter. The command first compares adjacent lines and then removes the second and succeeding duplications of a line. Duplicated lines must be adjacent.

Detailed explanation-4: -Remove duplicate lines with uniq The uniq command ensures that sequential identical lines are reduced to one.

Detailed explanation-5: -What are sort and uniq? Ordering and manipulating data in Linux-based text files can be carried out using the sort and uniq utilities. The sort command orders a list of items both alphabetically and numerically, whereas the uniq command removes adjacent duplicate lines in a list.

There is 1 question to complete.