Awk
Search and field separator - awk
This returns the users with access to bash
awk -F ':' '/\/bash/ {print $1}' /etc/passwd
-F
is the field separator with:
Seaching for/bash
in the file
Search and replace
Replace FIRST instances with sub()
Search for the string SEARCH-STR
and replace with REPLACE-STR
awk '{sub(/SEARCH-STR/, REPLACE-STR); print}' <file>
sub();
to find first instance of theSEARCH-STR
and substitute withREPLACE-STR
Replace ALL instances with gsub()
awk '{gsub(/SEARCH-STR/, REPLACE-STR); print}' <file>