Sign up ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. It's 100% free, no registration required.

These are the steps i am following.

`sed 's/[;]+$//g'`


  sed 's/;{1,\}$//g'
share|improve this question

2 Answers 2

up vote 4 down vote accepted

In basic regular expression you have to escape the + quantifier:

sed 's/;\+$//' file

Or use extended regular expression (if your sed supports them; GNU sed does):

sed -r 's/;+$//' file
share|improve this answer
There's no \+ in standard BRE, GNU BREs and a few others have it as an extension though. With standard BREs, + is written \{1,\}. In this case though, * will work just as well. sed 's/;*$//'. Some sed implementations support EREs with the -E option (which IMO makes more sense than -r). – Stéphane Chazelas Mar 11 '13 at 13:18
@StephaneChazelas, to get the exact + meaning would be sed 's/;;*$//', but that makes no real difference here. – vonbrand Mar 11 '13 at 14:08

I doesn't work if the file is with CRLF line terminators. To make it work you have to combine with the conversion :

sed 's/.$//'

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.