Basic Linux Tutorial
Introduction – What is it? Why to learn? Linux installation directory structures Boot process Run levels in Linux Desktop Environments Different shells BASH Internal and External Commands Basic Linux Commands Important files and directories in Linux Environmental and Shell Variables Command history in Linux Character classes in Linux Text editors vim nano Searching files Creating new files Viewing File Contents File commands File permissions and ownership WildCards (Globbing) in files File compression Directory commands xargs command in Linux Comparing files Searching patterns using grep command Translating the characters using tr command Extracting data using cut command Stream editing using sed command Data extraction and reporting using awk command Sorting the file or string input uniq command in Linux Difference between grep, tr, cut, sed and awk commands Hardware commands Hard disk and memory space commands Working with Processes Managing Jobs Working with cron jobs Service command in Linux Network commands Managing Users and Groups Other Popular commands Standard streams and Redirection Pipes Package Managers in Linuxuniq command in linux shell
uniq command is used to find only unique lines in a file.
uniq <file-name>
# This command will display only unique lines in the file.
# Note that only adjacent duplicate lines are removed. To remove all duplicates,
# you can sort the contents of file and then pipe the output to uniq command.
uniq -c <file-name>
# Here -c stands for count. It displays the count of occurences of each line.
uniq -d <file-name>
# Here -d stands for duplicate. It displays the duplicate lines once for each set of
# duplicate occurence.
uniq -D <file-name>
# It displays all occurrences of duplicate lines.
uniq -u <file-name>
# It displays only unique line.
uniq -c -w 4 <file-name>
# Use first 4 chars for checking uniqueness
uniq -D -s 4 <file-name>
# avoid comparing first 4 chars
uniq -D -f 4 <file-name>
# avoid compaing first 4 words
Web development and Automation testing
solutions delivered!!