Sort by Line Length
Sort file by line length. Original Article…
cat /etc/passwd | awk '{print length, 0}' | sort -n | awk '{1=""; print $0 }'
Sort file by line length. Original Article…
cat /etc/passwd | awk '{print length, 0}' | sort -n | awk '{1=""; print $0 }'
This will convert all the ico files in the folder to gif. It uses the final frame of the ico file to create the gif.
for i in *.ico; do convert `mogrify -identify i|awk '{print1}'|tail -n1` $i.gif; done
This command removes all the even lines from the file given as the argument
cat example.txt|awk 'NR%2==1'
Use this command if you want to know your command usage stats in the fish shell.
grep -v "^\#" ".config/fish/fish_history"|awk '{print $1}'|sort|uniq -c|sort -rn|head -n10
A better way to get the process id of an application. I recommend giving an alias for this command…
ps aux|grep firefox|awk '{print 2 "\t\t"12}'|head -n1
Replace firefox with the name of the application you are searching for.
One can use awk to get a specific column from a command output…
First column of the command
date|awk '{print $1}'
11th Column of the command
ps aux|awk '{print $11}'
Use a different Field separator
cat /etc/passwd|awk -F ':' '{print $1}'
[tags]awk,sed,shell,script,output,filter,text,cli,linux,string,separator[/tags]
Simple uses for awk
Get the second column from the output
ps aux | awk '{print $2}'
Use a different column separator
cat /etc/passwd|awk '{print $1}'
[tags]awk,cli,linux,command,filter,text[/tags]