I need some help to figure out how to use the sed command to only show the first column and last column in a text file. Here is what I have so far for column 1:
cat logfile | sed 's/\|/ /'|awk '{print $1}'
My feeble attempt at getting the last column to show as well was:
cat logfile | sed 's/\|/ /'|awk '{print $1}{print $8}'
However this takes the first column and last column and merges them together in one list. Is there a way to print the first column and last columns clearly with sed and awk commands?
Sample input:
foo|dog|cat|mouse|lion|ox|tiger|bar