[solved] remove pattern with sed

Hi,

i want to remove a certain pattern when i type pwd.

pwd will look like this:

..../....../....../Pat_logs/..../....../...../......

the dotted lines are just random directory names,
i want it to remove the "Pat_logs/...../....../....../" part

so for example:

a/b/c/d/Pat_logs/e/f/g

will become:

a/b/c/d/g

thanks!

---------- Post updated at 12:11 PM ---------- Previous update was at 11:57 AM ----------

I got this... but apparently it does nothing, so I don't think it finds the pattern correctly.

pwd | sed 's/\/PAT_logs\/\(\([:alnum:]+\)\/+\)//'

Hi.

PAT_logs is not the same as Pat_logs . Sed like most everything in Unix is case-sensitive.

$ echo a/b/c/d/Pat_logs/e/f/g | sed 's/\/*Pat_logs.*\//\//'
a/b/c/d/g
1 Like

Yes, everything should be PAT_logs, I just typed the post in the wrong case sorry.

pwd | sed 's/\\PAT_logs//'

Did you actually test that?

$ echo a/b/c/d/PAT_logs/e/f/g | sed 's/\\PAT_logs//g'
a/b/c/d/PAT_logs/e/f/g

thanks scotnn. thanks.

echo "/a/bc/def/PAT_logs/g/hi/jkl/" | sed "sz/PAT_logszzg'

it's better:

echo "/a/bc/def/PAT_logs/g/hi/jkl/" | sed "sz/PAT_logszz'

output:

/a/bc/def/g/hi/jkl

You must have booted your computer with the --ultra-lax-syntax option, because works "less" than the last one :wink:

I used "z" as "/" in s command s/REGEXP/REPLACEMENT/FLAGS

Hi.

I saw that. I was referring to the single quote at the end, and the extra / (which you have since removed).