使用shell脚本在“ [和]”之间提取值
"[""sometext1"", ""sometext2"", ""sometext3""]"
答案 0 :(得分:0)
echo '"[""sometext1"", ""sometext2"", ""sometext3""]"'|cut -d "[" -f2 | cut -d "]" -f1
答案 1 :(得分:0)
转义第一个'['
echo '"[""sometext1"", ""sometext2"", ""sometext3""]"'|
sed -r 's/"\[(.*)]"/\1/'
答案 2 :(得分:0)
使用Perl
$ echo '"[""sometext1"", ""sometext2"", ""sometext3""]"'
"[""sometext1"", ""sometext2"", ""sometext3""]"
$ echo '"[""sometext1"", ""sometext2"", ""sometext3""]"' | perl -ne ' m/\[(.*)\]/ and print $1 '
""sometext1"", ""sometext2"", ""sometext3""
$