Split string by multiple delimiters in bash - Linux Tips And Tricks

Опубликовано: 03 Октябрь 2024
на канале: Rabi Gurung
421
3

Learn how to split string by multiple delimiters in bash.

Command featured in this video.
uptime | awk -F'( |,|:)+' '{print $2,$3,$4}'

uptime | awk -F'( |,|:)+' '{print $2,$3,$4,$5,$6,$7,$8,$9,$10,$11,$12,$13,$14,$15,$16}'

uptime | awk -F'( |,|:|o)+' '{print $2,$3,$4,$5,$6,$7,$8,$9,$10,$11,$12,$13,$14,$15,$16}'

Additional useful command
uptime | awk -F'( |,|:)+' '{print $6,$7",",$8,"hours,",$9,"minutes."}'

#linux #ubuntu #redhat #bash