嗨,我刚开始使用"sed";我需要用bash脚本在特殊字符和空格之间显示文本。存在";类似的";这里有问题,但对我不起作用,因为我将在bash脚本中使用该变量。我需要帮助;sed";而不是";perl";我在本地没有index.html。我也在使用Linux。
这是我的变量:
output="$(wget -q http://software.opensuse.org/package/clementine -O - | sed -ne '/<p id="pkg-desc">/, /[.</p>]$/p')"
echo$输出
<p id="pkg-desc">Clementine is a modern music player and library organiser. Clementine is a port of Amarok 1.4, with some features rewritten to take advantage of Qt4.
关于如何在<p id="pkg-desc">
和某些文本之间显示文本,sed还有其他选择。</p>
?或者如何删除我的变量中的<p id="pkg-desc">
?
对不起,我的英语不好:/
这是gnu awk
版本的
output=$(wget -q software.opensuse.org/package/clementine -O - | awk -v RS='<p id="pkg-desc">' -F"</p>" 'NR==2{print $1}')
echo "$output"
Clementine is a modern music player and library organiser. Clementine is a
port of Amarok 1.4, with some features rewritten to take advantage of Qt4.
Features:
* Search and play your local music library
* Listen to internet radio from Last.fm and SomaFM
* Edit tags on MP3 and OGG files, organise your music
* Cross-platform - works on Windows, Mac OS X and Linux
* Native desktop notifications on Linux (libnotify) and Mac OS X (Growl)
output="$(wget -q software.opensuse.org/package/clementine -O - | sed -ne 's|<p id="pkg-desc">(.*)</p>$|1|p')"
output="
导致的escpae"
- 使用
|
作为sed分隔符,而不是/
,因为要查找的字符串中存在此字符(更易于管理( - 由于内部内容(仅(,使用
s///
而不是地址查找//,//
进行打印