What is the meaning of this sed command? sed 's% ^. * / %% '

I saw the bash command sed 's%^.*/%%'

Usually the general syntax for sed is sed 's/pattern/str/g', but in this he used s%^.*for part sin 's/pattern/str/g'.

My questions:
What does it mean s%^.*?
What is the point %%in the second part sed 's%^.*/%%'?

+3
source share
2 answers

% is an alternative delimiter, so you do not need to leave the slash line contained in the corresponding part.

So, if you were to write the same expression with /as a delimiter, it would look like this:

sed 's/^.*\///'

which is also hard to read.

; , .

+11

/, sed 's/pattern/str/'.

, . , , . %.

, .

+1

Source: https://habr.com/ru/post/1760227/


All Articles