サイト内検索:
check_attr_name : name 形式データの属性をチェックする
使い方とオプション
check_attr_name <check_file> <name_file>
--through <string>
--ngword <ng_file>
--ngthrough
n N (unsigned integer number)
s S (signed integer number)
f F (unsigned decimal fraction number)
v V (signed decimal fraction number)
e E (alphabetic characters)
a A (ASCII characters)
b B (alphabetic and numeric characters)
h H (half-width characters)
l L (half-width Katakana characters)
z Z (full-width characters)
k K (full-width Katakana characters)
x X (printable characters)
c C (check digit)
o O (non lower case letters)
j J (address letters = full-width + ASCII)
m M (email address)
<check_file> に記述されているタグ名、属性の指定に従って <name_file>のデータをチェックします。属性には桁数を付加することができます。属性が大文字なら桁数に等しい値を、小文字なら指定桁数以下の値を要求します。
<name_file> のタグは、タグ名_数値 であれば、_数値部分を取り除いたタグ名のみでチェックをします。
エラーがあった場合は、すべてのタグをチェックした後にエラー終了し、標準出力にタグ名と属性+桁数を出力します。–ngthrough を指定したときは、エラーが有っても正常終了します。
–through <string <name_file> のデータが <string> のうちいずれかに等しい場合は、チェックを実施しません。<string>のデフォルトは "_" です。このオプションを繰り返し使って複数の <string> を指定することができます。
–ngword <ng_file> z Z x X j J において、<ng_file> に記述されているマルチバイト文字はエラーとします。<ng_file> には、1行に1文字記述します。
通常のチェックは次の通りです。
$ cat check
A N3 <-- 3桁整数
B n4 <-- 4桁以下の整数
C x3 <-- 3桁以下の文字
D X6 <-- 6桁の文字
$ cat data
A 200
B 12345
C abcde
D_001 xxxxxx <--+- "D 6X" としてチェックされます
D_002 xxxxx <--+
D_003 xxxx <--+
$ check_attr_name check data
B n4
C x3
D_002 X6
D_003 X6
$ echo $?
1
–through オプションでチェックしない値を指定します。
$ cat data2
A 200
B @
C @
D_001 xxxxxx
D_002 @
D_003 @
$ check_attr_name --through @ check data2
$ echo $?
0
–ngthrough オプションで常に正常終了します。
$ cat data3
A 123
B 12345
$ check_attr_name check data3
B n4
$ echo $?
1
$ check_attr_name --ngthrough check data3
B n4
$ echo $?
0
Fri Jan 15 10:07:11 JST 2021
1
© 2021 Universal Shell Programming Laboratory site