Using awk how can I print the record so it looks like:
Department: TRIHEALTH/PEDIATRICS
(basically print $2 and $1 with an OFS = "/"). I've tried several
iterations and.
just. can't. get. it. today.
The problem is that it's not $2 and $1 that you want to swap, rather
you have a hierarchical structure, where $1 is "Department:" and $2
is "TRIHEALTH/PEDIATRICS".
Awk provides a split function that you can apply on arbitrary strings.
$1=="Department:" { split($2,arr,"/"); print $1,arr[2]"/"arr[1] }
Janis
Though an acceptable solution has been posted, I'm including one more,
along the lines of what the OP sems to have tried.
awk 'BEGIN {FS="[ /]";} {print $1" "$3"/"$2;}'
This way, you can specify that a " " or a / can be used as an FS and
then print the fields desired.
Of course, you have to print the space and / too.
Sashi