Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
私は次のような文字列を持っています
70100100700FF0101621B52FF55FFFFAFD30177078181C7820
52FF55そして、その部分に続く8文字が必要です。したがって、結果は になりますFFFFAFD3。これ52FF55は静的で、他のすべての文字列部分は可変です。
52FF55
FFFFAFD3
bash シェル スクリプトを使用する必要があります。
grep -oPで使用lookbehind regex:
grep -oP
lookbehind regex
grep -oP '(?<=52FF55).{8}' <<< "$s" FFFFAFD3
またはsed -r:
sed -r
sed -r 's/^.*52FF55(.{8}).*$/\1/' <<< "$s" FFFFAFD3