tecot@cmu-cs-k.ARPA (Edward Tecot) (06/11/85)
I am working on a program which will have a data base similar to /etc/passwd or /etc/inittab. Are there any libraries which support these type of files? Specifically, I would like to be able to search for a record based on a certain key, and ask for the nth field in that record.
carl@bdaemon.UUCP (carl) (06/13/85)
> I am working on a program which will have a data base similar to /etc/passwd > or /etc/inittab. Are there any libraries which support these type of files? > Specifically, I would like to be able to search for a record based on a > certain key, and ask for the nth field in that record. Why not: grep key file | awk -F: 'print $n' where $n is the nth field? Cral Brandauer
steven@luke.UUCP (Steven List) (06/16/85)
In article <298@bdaemon.UUCP> carl@bdaemon.UUCP (carl) writes: >> I am working on a program which will have a data base similar to /etc/passwd >> or /etc/inittab. Are there any libraries which support these type of files? >> Specifically, I would like to be able to search for a record based on a >> certain key, and ask for the nth field in that record. > >Why not: > > grep key file | awk -F: 'print $n' > >where $n is the nth field? > >Cral Brandauer ^^^^? How about: grep "^key" file | awk -F: '{print $n}' Good advice is only good if it's accurate. -- *** * Steven List @ Benetics Corporation, Mt. View, CA * {cdp,greipa,idi,oliveb,sun,tolerant}!bene!luke!steven ***
guy@sun.uucp (Guy Harris) (06/20/85)
> How about: > > grep "^key" file | awk -F: '{print $n}' Which only works if the key field is the first field in the record - and will also match "keywest". Besides, the guy asked for "libraries" - i.e., he presumably wants the moral equivalent of "getpwnam" and "getpwuid" and the like. Guy Harris