awk: Preserve multiple field separators
问题 I'm using awk to swap fields in a filename using two different field separators. I want to know if it's possible to preserve both separators, '/' and '_', in the correct positions in the output. Example: I want to change this: /path/to/ example_file _123.txt into this: /path/to/ file_example _123.txt I've tried: awk -F "[/_]" '{ t=$3; $3=$4; $4=t;print}' file.txt but the field separators are missing from the output: path to file example 123.txt I've tried preserving the field separators: awk