CyberKeeda In Social Media

SED to remove last character for a line or every line

So this sed command will help you to remove the unwanted string from your word to make your life more automotive at all.

Lets take an example,

[icinga@cyberkeeda ~]$ cat myfile.txt


I have a word as  sampletext,  and i need to remove sign  ,  from the above word to look it as sampletext only.

Hence i can SED to trim that specific word.

[icinga@cyberkeeda ~]$ sed -i 's/,$//' myfile.txt
Now, if if you don't care whatever the last character
 it may be , or % or & 
It must be removed then use the below command
[icinga@cyberkeeda ~]$ sed 's/.$//' myfile.txt

No comments:

Post a Comment

Designed By Jackuna