6
1
in the file /etc/passwd
we have the so called GECOS fields
(which stands for "General Electric Comprehensive Operating System"), that is:
username:password:userid:groupid:gecos:home-dir:shell
Where GECOS
are divided as:
:FullName,RoomAddress,WorkPhone,HomePhone,Others:
And Others
are divided in as many commas as you like:
:FullName,RoomAddress,WorkPhone,HomePhone,Other1,Other2,Other3:
In the man chfn
pages one can read:
The other field is used to store accounting information used by other applications.
Now, for an application developer (I'm interested in C language
, system calls
and/or bash script
) which is the best way to grab this information?
And considering just the Bash
environment, given that finger
command cannot display the others
fields (or at least I don't see how), what are other commands that can? I know that chfn
not only show, but allow them to be changed. What if one is to just output it to stdout
?
For example in bash you can extract the field with
awk -F ":" '{print $5}' /etc/passwd
... then you can process again the string (you can do with a single call too viasplit
ting the field with the split function. – Hastur – 2016-01-26T16:45:28.863I was wondering if I could use a command specific to the job, instead of text processing commands (
awk
,sed
,cat
,grep
,cut
, and alike). Also, how applications would read this? Any example of an application that do use theother
field? – Dr Beco – 2016-01-26T17:05:39.280