(Video materials in preparation)
nameread : Read a file that is in NAME format
Usage : nameread <name> <namefile>
Options : -l
-e
-s<c>
-n<string>
--index
Version : Tue Jan 9 09:02:34 JST 2024
Edition : 1
Reads a value from a file <namefile> in NAME format by specifying
the name. If <namefile> is omitted or specified as "-" then the
command will read from standard input.
The -l option will also output the name as well as the value.
The -e option will use a regular expression to specify the name.
The -s option will replace whilespaces by the character <c>.
(If <c> is omitted, whitespaces are deleted.)
The -n option will set <string> to the null data.
The --index option specfies the indexed name.
$ cat namefile
A usp
B usp laboratory
C
# Normal Output
$ nameread A namefile
usp
# Output the name and the value together
$ nameread -l A namefile
A usp
# Name format data includes whitespace
$ nameread B namefile
usp laboratory
# Replace whitespace with underscore
$ nameread -s_ B namefile
usp_laboratory
# Delete whitespace
$ nameread -s B namefile
usplaboratory
# When reading a field with no value, an empty line is output
$ nameread C namefile
# Set string to null data
$ namread -n @@@ C namefile
@@@
# When specifying a name that doesn't exist, nothing is output
(-n option is ignored)
$ nameread D namefile
# Specify a regular expression
$ cat namefile2
A_01 1
A_02 2
A_03 3
A_10 5
AA_1 7
$ nameread -e '^A_[0-9]+$' namefile2
1
2
3
5
$ nameread -el '^A_[0-9]+$' namefile2
A_01 1
A_02 2
A_03 3
A_10 5
# --index option makes this simple and much faster
$ nameread -l --index A namefile2
A_01 1
A_02 2
A_03 3
A_10 5
Old -d option (current -s option) will not be supportes
Old -i option (current -n option) will not be supportes