Reputation: 1
I'm new to sed
.
Can someone explain what sed -i "s/,$//'
means?
Upvotes: 0
Views: 143
Reputation: 9629
Your regex doesn't seems correct, the good writting could be:
sed -i 's/,$//' "filename"
I replaced the opening double quote ("
) by a simple ('
)
Let's explain:
-i
in place: the file given in argument will be changed.s
substitute: s/pattern/string/
it a replacement regex, matched pattern
will be replaced with string
,$
: will match quote (,
) followed by a line feed (\n
)
: the pattern will be simply deleted.So you sed command will transform a file like
a,b,c,
e,f,g
h,i,j,,
into
a,b,c
e,f,g
h,i,j,
Upvotes: 1