NeilSec: Security Learning Blog

Pentesting, infosec, hacking, learning.

  • Home
  • Knowledgebase
You are here: Home / Linux / awk

awk

2018-01-22 by Neil Leave a Comment

awk is a pattern scanning and processing language. However it can be used more simply as a command line filter that operates at the field level rather than the line level like grep does.

A typical awk statement:

awk -F: ‘{print $3}’

This is in two sections. The first is

awk -F: which means use a colon as the field separator
if you used -F” “, that would mean use a space as the field separator

The second part is:

‘{print $3}’

This is saying to print the 3rd field as defined by the field seperator by -F

For example, the passwd file gives us entries such as this line:

root:x:0:0:root:/root:/bin/bash

Here the fields are seperated by colons. The first field is the username, root in this case. So if we want a list of all the users in that file we use:

cat /etc/passwd | awk -F: ‘{print $1}’

 

Filed Under: Linux

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

About Me

I’m currently a systems admin / consultant at a IT firm who looks after the computer systems of small businesses in the UK. IT security is only a part of that job. However I’ve always enjoyed breaking into, getting around, subverting and otherwise hacking things, systems and ideas. In tackling some low-level IT security tasks I reignited my interest in the field and this blog charts my progress in the world of Computer Security, legal Hacking, Penetration Testing, Infosec – whatever you want to call it. As a Windows guy I’m learning about Linux, shell-scripting, python and all the other skills needed in this field.

Tags

Apache Boot-to-Root CTF curl dib Dirbuster FreeBSD Hack The Box Linux mysql NFS Penetration Testing PHP RCE shell VulnHub Wordpress

Categories

© 2023 · NeilSec;