Extract emp number from an error file.


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Extract emp number from an error file.
# 1  
Old 05-29-2003
Question 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.
Smilie
# 2  
Old 05-30-2003
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.
# 3  
Old 05-30-2003
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]"
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Perl extract number from file & write to file

I have 1 file that has elements as follows. Also the CVR(10) and the word "SAUCE" only appear once in the file so maybe a grep command would work? file1 CVR( 9) = 0.385E+05, ! VEHICLE CVR(10) = 0.246E+05, ! SAUCE CVR(11) = 0.162E+03, ! VEHICLE I need to extract the... (6 Replies)
Discussion started by: austinj
6 Replies

2. Shell Programming and Scripting

Extract string from multiple file based on line count number

Hi, I search all forum, but I can not find solutions of my problem :( I have multiple files (5000 files), inside there is this data : FILE 1: 1195.921 -898.995 0.750312E-02-0.497526E-02 0.195382E-05 0.609417E-05 -2021.287 1305.479-0.819754E-02 0.107572E-01 0.313018E-05 0.885066E-05 ... (15 Replies)
Discussion started by: guns
15 Replies

3. UNIX for Dummies Questions & Answers

Extract n number of lines from a file successively

Hello, I have a file with over 100,000 lines. I would like to be able extract 5000 lines at a time and give it as an input to another program. sed -n '1,5000p' <myfile> > myOut Similarly for 5001-10000 10001-15000 .... How can I do this in a loop? Thanks, Guss (5 Replies)
Discussion started by: Gussifinknottle
5 Replies

4. Shell Programming and Scripting

Extract a number from a line in a file and sed in another copied file

Dear all, I am trying to extract a number from a line in one file (task 1), duplicate another file (task 2) and replace all instances of the strings 300, in duplicated with the extracted number (task 3). Here is what I have tried so far: for ((k=1;k<4;k++)); do temp=`sed -n "${k}p"... (2 Replies)
Discussion started by: mnaqvi
2 Replies

5. Shell Programming and Scripting

How to extract specific data and count number containing sets from a file?

Hello everybody! I am quit new here and hope you can help me. Using an awk script I am trying to extract data from several files. The structure of the input files is as follows: TimeStep parameter1 parameter2 parameter3 parameter4 e.g. 1 X Y Z L 1 D H Z I 1 H Y E W 2 D H G F 2 R... (2 Replies)
Discussion started by: Daniel8472
2 Replies

6. Shell Programming and Scripting

extract number range from a file

Hi Everyone, a.txt 1272904667;1272904737;1 1272904747;1272904819;1 1272904810;1272904857;1 1272904889;1272904926;1 1272905399;1272905406;1 1272905411;1272905422;1 if i want to get the record, when the a.txt 1st field is between 1272904749 and 1272905399, any simple way by using awk,... (1 Reply)
Discussion started by: jimmy_y
1 Replies

7. UNIX for Dummies Questions & Answers

Extract a specific number from an XML file based on the start and end tags

Hello People, I have the following contents in an XML file ........... ........... .......... ........... <Details = "Sample Details"> <Name>Bob</Name> <Age>34</Age> <Address>CA</Address> <ContactNumber>1234</ContactNumber> </Details> ........... ............. .............. (4 Replies)
Discussion started by: sushant172
4 Replies

8. Shell Programming and Scripting

Print EMP ID

Hi, Please find the transaction details in my log. 02:11:02 : Number of parameters - 7 02:11:02 : List of parameters : sam@intro.com 2345 Sam 02:11:05:The parameters received are :: ID:sam@intro.com Emp Number :2345 Login Id :Sam Login Date :27/08/2009 Due to some java... (3 Replies)
Discussion started by: Sekar1
3 Replies

9. Shell Programming and Scripting

extract the lines between specific line number from a text file

Hi I want to extract certain text between two line numbers like 23234234324 and 54446655567567 How do I do this with a simple sed or awk command? Thank you. ---------- Post updated at 06:16 PM ---------- Previous update was at 05:55 PM ---------- found it: sed -n '#1,#2p'... (1 Reply)
Discussion started by: return_user
1 Replies

10. Shell Programming and Scripting

extract a number within an xml file

Hi Everyone, I have an sh script that I am working on and I have run into a little snag that I am hoping someone here can assist me with. I am using wget to retrieve an xml file from thetvdb.com. This part works ok but what I need to be able to do is extract the series ID # from the xml and put... (10 Replies)
Discussion started by: tret
10 Replies
Login or Register to Ask a Question