1

I have a file fooap.p and I am using sed command to get the output like fooap.

echo fooap.p | sed s/\.\p//g 

but the output I am getting is just foo.

Am I missing something?

closed as unclear what you're asking by αғsнιη, Stephen Rauch, Romeo Ninov, Anthon, Jeff Schaller Jul 19 '17 at 21:18

Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.

  • 2
    you're using sed on the file name? In order to rename it, or to do something else? – Jeff Schaller Jul 19 '17 at 17:34
2

First, you need to quote the pattern for sed. Then, you need to escape the dot, so that it's treated literally. Thus, try this:

echo fooap.p | sed 's/\.p//'

The last g in your code is superfluous.

1
sed 's/\.p$/p/' /path/to/input

Not the answer you're looking for? Browse other questions tagged or ask your own question.