using grep with sed
Hi guys
Here is a weird one...at least for me. i have a test file where some lines contain the world e-mail followed by some e-mails. I want to remove the last comma (,) character of each of these lines . I can do this with the below command Code:
cat test.txt |grep emails|sed 's/,$//' Code:
cat test.txt|grep emails|sed -i 's/,$//' How do you overcome this one? Any ideas? Thanks |
You don't need cat, you don't need grep.
You should be able to do it all in one sed command - problem goes away. |
Quote:
|
sed -i has no meaning if you use sed with pipe as input
|
Well i came up with this solution
Code:
sed 's/,$//' test.txt |
Have a look at the manpage for sed in the section "Addresses". You can use regex to select the lines you want - the regex can be a simple string.
|
try: sed '/email/s/.$//' test.txt
|
All times are GMT -5. The time now is 11:32 AM. |