- 论坛徽章:
- 2
|
回复 1# o06v90o
- y=/b/
- echo 'a/b/c/d
- e/f/g' |sed -n '\#'$y'#p'
- a/b/c/d
复制代码
info sed
'\%REGEXP%'
(The '%' may be replaced by any other single character.)
This also matches the regular expression REGEXP, but allows one to
use a different delimiter than '/'. This is particularly useful if
the REGEXP itself contains a lot of slashes, since it avoids the
tedious escaping of every '/'. If REGEXP itself includes any
delimiter characters, each must be escaped by a backslash ('\').
The following two commands are equivalent. They print lines which
start with '/home/alice/documents/':
sed -n '/^\/home\/alice\/documents\//p'
sed -n '\%^/home/alice/documents/%p'
sed -n '\;^/home/alice/documents/;p' |
|