I'm trying to remove periods that are at the end of line in a text file. Some lines have periods at the end, some don't:
$cat textfile
sometexthere.123..22.no_period
moretext_with_period. **<-- remove this period**
no_period_here_either
period. **<-- remove this period**
I've tried this, but it doesn't seem to work:
sed 's/\.$//g' textfile > textfile2
(GNU sed version 4.2.1)
Thanks
This is a shot in the dark, but I had this problem before when I tried to mix Windows files with Linux files. Windows adds an extra \r
on every line break (in addition to the standard \n
)Have you tried using dos2unix?
[user@localhost ~]$ cat testfile
abc
def.
[user@localhost ~]$ sed 's/\.$//g' testfile
abc
def.
[user@localhost ~]$ dos2unix testfile
dos2unix: converting file testfile to UNIX format ...
[user@localhost ~]$ sed 's/\.$//g' testfile
abc
def
[user@localhost ~]$
Example this -
[user@localhost ~]$ cat temp.txt
this is a text created on windows
I will send this to unix
and do cat command.
[user@localhost ~]$ cat -v temp.txt
this is a text created on windows^M
I will send this to unix^M
and do cat command.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With