user1551585
user1551585

Reputation: 15

Print text at end of semicolon Sed/awk

I've this strings in a file that looks like aaaaa;bbbbbbb;ccccc\n and aaaaa;bbbbbb\n the idea is only to show the text between the last semicolon and newline. Output will be

ccccc
bbbbb

etc.

Thought that I could do it with sed -e [:]$ | awk -F '\n' {print $1}

Upvotes: 1

Views: 489

Answers (2)

Igor Chubin
Igor Chubin

Reputation: 64603

There are many ways to solve the task:

sed 's/.*;//'
awk -F';' '{print $NF}'
rev | cut -d';' -f 1 | rev

Upvotes: 3

choroba
choroba

Reputation: 242038

Just delete everything up to the last semicolon:

sed 's/.*;//'

Upvotes: 2

Related Questions