Skip to main content
added 57 characters in body
Source Link
Ed Morton
  • 35.9k
  • 6
  • 25
  • 60

With GNU awk foror any other awk that supports multi-char RS (e.g. newer versions of mawk):

$ awk -v RS='[[:space:]]+' '$0!=""' file Cat Dog Soup Rat Cass Audrey 

$ awk -v RS='[[:space:]]+' '$0!=""' file2 Once upon a midnight dreary while I pondered weak and weary Over many a quaint and curious volume of forgotten lore 

With GNU awk for multi-char RS:

$ awk -v RS='[[:space:]]+' '$0!=""' file Cat Dog Soup Rat Cass Audrey 

$ awk -v RS='[[:space:]]+' '$0!=""' file2 Once upon a midnight dreary while I pondered weak and weary Over many a quaint and curious volume of forgotten lore 

With GNU awk or any other awk that supports multi-char RS (e.g. newer versions of mawk):

$ awk -v RS='[[:space:]]+' '$0!=""' file Cat Dog Soup Rat Cass Audrey 

$ awk -v RS='[[:space:]]+' '$0!=""' file2 Once upon a midnight dreary while I pondered weak and weary Over many a quaint and curious volume of forgotten lore 
Source Link
Ed Morton
  • 35.9k
  • 6
  • 25
  • 60

With GNU awk for multi-char RS:

$ awk -v RS='[[:space:]]+' '$0!=""' file Cat Dog Soup Rat Cass Audrey 

$ awk -v RS='[[:space:]]+' '$0!=""' file2 Once upon a midnight dreary while I pondered weak and weary Over many a quaint and curious volume of forgotten lore