Last active
October 1, 2021 08:08
-
-
Save naotea/65a9738ed6947d060c4c44658cedbb7b to your computer and use it in GitHub Desktop.
SVGファイル群の特定レイヤーのテキストをgrepで検索し、対象文字列のみ表示。 xgrepは無い環境で。
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# find text from Layer_1 in SVG files. | |
svgpath='/svg/path' #svg path | |
svgname="*.svg" #svg extension | |
mtime=30 #search file only from 30days before (find -mtime -30) | |
targetstr='Tareget Text regexp' #serach target text in Perl Regexp | |
layername='Layer_1' #search target layer in Perl Regexp (grep -P) | |
find $svgpath -name $svgname -mtime -$mtime -exec grep -lP ">$targetstr</text" {} \; \ | |
|xargs -n 1 grep -oHP "(?<=id=\")$layername(?=\")|(?<=>)$targetstr(?=</text)" \ | |
|sed -e ":$targetstr/: $targetstr/g" \ | |
|awk -F'[:]' '{file[NR]=$1} {if(file[NR]!=file[NR-1]){"ls -l --time-style=long-iso "$1"" |getline f;printf("\n%s\n%s\n",f,$2)else{print $2}' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment