[英]how can i get the content of between two special strings in shell
我有兩個特殊字符,我想在shell中獲取它們之間的內容。
不要使用awk,因為我的linux找不到awk。
echo "ABxxxDE" | sed -e 's/AB\(.*\)DE/\1/g'
將打印出:
xxx
$ sed -n '/WORD1/,/WORD2/p' /path/to/file
$ sed -n '/FOO/,/BAR/p' test.txt
echo "This is a #TEST%" | grep -o \#[a-zA-Z.0-9]*\%
將產生
#TEST%
您也可以使用sed去除特殊字符。
echo "This is a #TEST%" | grep -o \#[a-zA-Z.0-9]*\% | sed 's/#//g' | sed 's/%//g'
屈服
TEST
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.