当前位置: 技术问答>linux和unix
请问文件读取操作
来源: 互联网 发布时间:2015-03-13
本文导语: # # DocumentRoot: The directory out of which you will serve your # documents. By default, all requests are taken from this directory, but # symbolic links and aliases may be used to point to other locations. # # DocumentRoot "/www/htdocs" DocumentR...
#
# DocumentRoot: The directory out of which you will serve your
# documents. By default, all requests are taken from this directory, but
# symbolic links and aliases may be used to point to other locations.
#
# DocumentRoot "/www/htdocs"
DocumentRoot "/webex_doc/sitelink"
#
我要怎么样才能准确的得出 DocumentRoot "/webex_doc/sitelink" 中的 "/webex_doc/sitelink"?,而不至于得出了上一行中的路径?
不好意思,这是我的第一个 shell,希望得到指教。
# DocumentRoot: The directory out of which you will serve your
# documents. By default, all requests are taken from this directory, but
# symbolic links and aliases may be used to point to other locations.
#
# DocumentRoot "/www/htdocs"
DocumentRoot "/webex_doc/sitelink"
#
我要怎么样才能准确的得出 DocumentRoot "/webex_doc/sitelink" 中的 "/webex_doc/sitelink"?,而不至于得出了上一行中的路径?
不好意思,这是我的第一个 shell,希望得到指教。
|
比如说文件名为a.txt
可以用 cat a.txt | grep ^DocumentRoot | awk '{ print $2}' 试试
可以用 cat a.txt | grep ^DocumentRoot | awk '{ print $2}' 试试
|
补充
s/pattern1/pattern2/g - 将pattern1替换成pattern2, g表示替换所有match的内容
/可以用其他符号代替
s/pattern1/pattern2/g - 将pattern1替换成pattern2, g表示替换所有match的内容
/可以用其他符号代替