Posts Tagged With: awk

Sort by Line Length

Tagged with: , , , , ,

Sort file by line length. Original Article…


cat /etc/passwd | awk '{print length, $0}' | sort -n | awk '{$1=""; print $0 }'
1 Comment »

Convent Ico to Gif

Tagged with: , , , , ,

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 '{print $1}'|tail -n1` $i.gif;  done   
No Comments »

Remove Even Lines

Tagged with: , , , ,

This command removes all the even lines from the file given as the argument


cat example.txt|awk 'NR%2==1'
No Comments »

Fish Shell Command History Meme

Tagged with: , , , , , , , ,

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
No Comments »

Better Way to find Process ID of an Application in Linux

Tagged with: , , , , , , ,

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.

No Comments »

Fetch columns of Output using Awk

Tagged with: , , , , , , , , , ,

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]

No Comments »

Using Awk

Tagged with: , , , , ,

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]

No Comments »