Chop everything after last delimiter on each line in a file using sed

In this case, a space is the delimiter.

cat file | sed 's/\ [^\ ]*$//'

In this case a : is the delimiter.

cat file | sed 's/\:[^\:]*$//'

In this case a , is the delimiter.

cat file | sed 's/\,[^\,]*$//'

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *