Skip to content

Instantly share code, notes, and snippets.

@mystelynx
Created April 9, 2013 11:55
Show Gist options
  • Save mystelynx/5345109 to your computer and use it in GitHub Desktop.
Save mystelynx/5345109 to your computer and use it in GitHub Desktop.
対象のファイルの各行が、Regexにマッチしてればstdoutへ、してなければstderrへ出す
function validate() {
file=$1
regex=$2
cat $file | awk "
/$regex/ {
print \$0
next
}
!/$regex/ {
printf \"ERR-%05d:%s\n\", NR, \$0 > \"/dev/stderr\"
}
"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment