head : display first 10 lines of a file. J join : display the combination (lines with command field) of two fields. K kill : send a signal to terminate a process. ksh : invoke the korn shell. L line : read a specific line out of a file (shell script usage). ln : create a li...
Remove duplicate lines using awk $ awk '!($0 in array) { array[$0]; print }' temp Print all lines from /etc/passwd that has the same uid and gid $awk -F ':' '$3==$4' passwd.txt Print only specific field from a file. $ awk '{print $2,$5;}' employee.txt More awk examp...
The uniq command eliminates duplicate lines in a file.The sort command works on each line of a text file. Normally, it is used to order the contents of files containing data such as names, addresses, and phone numbers. In the following example, we use grep to search for index entries, ...
# ps axjf# All processes in a tree format (Linux)# ps aux | grep 'ss[h]'# Find all ssh pids without the grep pid# pgrep -l sshd# Find the PIDs of processes by (part of) name# echo $$# The PID of your shell# fuser -va 22/tcp# List processes using port 22 (Linux)# pmap...
Remove duplicate lines using awk $ awk '!($0 in array) { array[$0]; print }' temp Print all lines from /etc/passwd that has the same uid and gid $awk -F ':' '$3==$4' passwd.txt Print only specific field from a file. $ awk '{print $2,$5;}' employee.txt More awk examp...
Add line number for all non-empty-lines in a file $ sed '/./=' thegeekstuff.txt | sed 'N; s/\n/ /' More sed examples:Advanced Sed Substitution Examples 6. awk command examples Remove duplicate lines using awk $ awk '!($0 in array) { array[$0]; print }' temp ...
awk command examples Remove duplicate lines using awk $ awk '!($0 in array) { array[$0]; print }' temp Print all lines from /etc/passwd that has the same uid and gid $awk -F ':' '$3==$4' passwd.txt Print only specific field from a file. $ awk '{print $2,$5;}' ...
Add line number for all non-empty-lines in a file $ sed '/./=' thegeekstuff.txt | sed 'N; s/\n/ /' More sed examples: Advanced Sed Substitution Examples 6. awk command examples Remove duplicate lines using awk $ awk '!($0 in array) { array[$0]; print }' temp Print...
Tutorial on using uniq, a UNIX and Linux command for reporting or filtering repeated lines in a file. Examples of showing a count of occurrences, showing only repeated lines and ignoring characters and specific fields.
(正则表达式)>>What is a regular expression A regular expression is just a pattern of characters used to match the same characters in a search.A regular expression can be controlled by special metacharacters.Regular Expressions can be used on:Commamd lines in Shell Command lines in Editors ...