...
Be aware of the default field delimiter for the various bash utilities, and how to change them:
utility | default delimiter | how to change | example |
---|---|---|---|
cut | Tab | -d or --delimiter option | cut -d ':' -f 1 /etc/passwd |
sort | whitespace (one ore more spaces or Tabs) | -t or --field-separator option | sort -t ':' -k1,1 /etc/passwd |
awk | whitespace (one ore more spaces or Tabs) Note: some older versions of awk do not treat Tabs as field separators. |
|
|
|
|
cat /etc/passwd | awk -F ":" '{print $1}' | |||
join | one or more spaces | -t option |
|
perl | whitespace (one ore more spaces or Tabs) when auto-splitting input with -a | -F'/<pattern>/' option | cat |
/etc/fstab | grep -v '^#' | perl -F'/\ |
s+/' -a -n -e 'print "$F[ |
1]\t$F[ |
0]\n";' | |||
read | whitespace (one or more spaces or Tabs) | IFS= (input field separator) option | Note that a bare IFS= removes any field separator, so whole lines are read each loop iteration. |