a27wang
1
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:]+\)\/+\)//'
Scott
2
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
a27wang
3
Yes, everything should be PAT_logs, I just typed the post in the wrong case sorry.
pwd | sed 's/\\PAT_logs//'
Scott
5
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
Scott
7
You must have booted your computer with the --ultra-lax-syntax
option, because works "less" than the last one
I used "z" as "/" in s command s/REGEXP/REPLACEMENT/FLAGS
Scott
9
Hi.
I saw that. I was referring to the single quote at the end, and the extra / (which you have since removed).