hi want remove last comma line. example:
input:
this,is,a,test
desired output:
this,is,a test
i able remove last comma if last character of string using below command: (however not want)
echo "this,is,a,test," |sed 's/,$//' this,is,a,test
same command not work if there more characters past last comma in line.
echo "this,is,a,test" |sed 's/,$//' this,is,a,test
i able achieve results using dirty way calling multiple commands, alternative achieve same using awk or sed regex ?(this want)
echo "this,is,a,test" |rev |sed 's/,/ /' |rev this,is,a test
$ echo "this,is,a,test" | sed 's/\(.*\),/\1 /' this,is,a test
with lookbehind,
$ echo "this,is,a,test" | perl -pe 's/.*\k,/ /' this,is,a test
*
greedy, tries match as possible.
Comments
Post a Comment