#!/usr/bin/env bash # -d sets the delimiter, -f picks fields 1 and 3 printf '%s\n' "root:x:0:0" "daemon:x:1:1" | cut -d: -f1,3
pick fields by delimiter