Extract emp number from an error file.

I have to investigate error files created by SQL from an Oracle database. I would like to get just the emp number and pass this to another process, to out put specific details relating to that employee.
Typical contents of an error file;
STAFF_NUM TERM_DT DETAIL
------------ ----------- ------------------------
43440 11-AUG-2003 CREW_POSITION_FLY_V
48947 NULL CREW_BASE_V
48947 NULL CREW_CONTRACTS_V
48947 NULL CREW_DETAILS_V
48947 NULL CREW_EMPLOYMENT_STATUS_V
48947 NULL CREW_RANK_V
48947 NULL CREW_RSRC_GRP_V

Can I get just the column with the emp number, stripping of duplicate numbers, and pass this into another script that uses the emp number to produce a detailed report on their history.

Thanks for the help.
:slight_smile:

If the empid is a fixed length you could use cut to essentially cut that column out of the file and then do a sort -u to get rid of dups. Another option is to use awk '{print $1}' if the empid is variable length but always followed by white space. You would then use sort as well to get rid of dups. You can pass the resulting list to another script, programming, etc.

Since awk will give you the first field of each line, its output will include STAFF_NUM and ------------ from the first two lines. One way you could get rid of this is to use a grep command on the output of awk before passing it to the sort command.. something like: grep "^[0-9]"