This is my file:
<code>abc.test.com
efg.test.com:80/test1/123/xyz
xyz.test.com:443/test1
xab.test.com:80
lmn.test.com/100
com.test.com:10
</code>
<code>abc.test.com
efg.test.com:80/test1/123/xyz
xyz.test.com:443/test1
xab.test.com:80
lmn.test.com/100
com.test.com:10
</code>
abc.test.com
efg.test.com:80/test1/123/xyz
xyz.test.com:443/test1
xab.test.com:80
lmn.test.com/100
com.test.com:10
I am trying to remove all characters after the string “.com”, but I want to include “.com” in it.
I tried sed ‘s/.com.*//’, however it seems to exclude “.com” as well:
<code>$ cat test1.txt | grep .com | sed 's/.com.*//'
abc.test
efg.test
xyz.test
xab.test
lmn.test
com.test
</code>
<code>$ cat test1.txt | grep .com | sed 's/.com.*//'
abc.test
efg.test
xyz.test
xab.test
lmn.test
com.test
</code>
$ cat test1.txt | grep .com | sed 's/.com.*//'
abc.test
efg.test
xyz.test
xab.test
lmn.test
com.test
Is there a way to remove all characters after a particular string, however the output should still have that string it.