Txt

Byte sized tech know-how.

  • Home
  • About

Tag Archives: awk

14 Apr

Sort by Line Length

Sort file by line length. Original Article…


cat /etc/passwd | awk '{print length, 0}' | sort -n | awk '{1=""; print $0 }'
admin Posted in Code, Command Line, Linux awk, command, length, line, Linux, sort 1 Comment
26 May

Convent Ico to Gif

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   
admin Posted in Command Line, Linux awk, convert, favicon, ico, icon, mogrify Leave a comment
27 Apr

Remove Even Lines

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


cat example.txt|awk 'NR%2==1'
admin Posted in Uncategorized awk, command, even, line, Linux Leave a comment
16 Apr

Fish Shell Command History Meme

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
admin Posted in Command Line, Linux awk, command, fish, grep, history, Linux, meme, sed, shell Leave a comment
14 Sep

Better Way to find Process ID of an Application in Linux

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.

admin Posted in Command Line, Linux awk, cli, command, grep, id, Linux, process, ps Leave a comment
09 Jul

Fetch columns of Output using Awk

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]

admin Posted in Uncategorized awk, cli, filter, Linux, output, script, sed, separator, shell, string, text Leave a comment
11 May

Using Awk

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]

admin Posted in Command Line, Linux awk, cli, command, filter, Linux, text Leave a comment

Post navigation

Categories

  • Code
  • Command Line
  • Configuration
  • CSS
  • HTML
  • internet
  • JavaScript
  • Linux
  • Mobile
  • Perl
  • PHP
  • Python
  • Ruby
  • Uncategorized

Meta

  • Log in
  • Entries feed
  • Comments feed
  • WordPress.org
Fruitful theme by fruitfulcode Powered by: WordPress
↑