process field 1 depending on field 6


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting process field 1 depending on field 6
# 1  
Old 07-24-2012
process field 1 depending on field 6

Hi

I am abigginer to unix .I have a file which contains data like this .

Code:
fiusdcanlt_fmrbgmusd1_run    07/23/2012 20:11:18  07/23/2012 20:12:20  SU 10861341/1
fiusdcanlt_fmrbgmusd2_run    07/23/2012 20:12:22  07/23/2012 20:21:26  SU 10861341/1
fiusdcanlt_fmrbgmusd3_run    07/23/2012 20:34:18  07/23/2012 20:34:56  SU 10861341/1
fiusdcanlt_fmrbgmusd4_run    07/23/2012 20:48:13  07/23/2012 20:54:54  SU 10861341/1
Timecheck 20:30 EST
fiusdcanlt_fmrcmousd1_run    07/23/2012 21:05:54  07/23/2012 23:52:40  SU 10862038/1
fiusdcanlt_lbecalusd1_run    07/23/2012 20:07:06  07/23/2012 20:09:32  SU 10861218/1


Now I want to iterate through each line .The first column is job and 6 th column is job status.If the job status is success then script has to do nothing. But if the job status is IN ,then it has to take the job name and execute the the command jd job_name;

please help .what I am trying to acheive here is I need to process through the each line ,and depending on the status of field (job status ) i need to process the field 1 (jobname).

Moderator's Comments:
Mod Comment Please use code tags next time for your code and data.

Last edited by zaxxon; 07-24-2012 at 09:28 AM.. Reason: code tags
# 2  
Old 07-24-2012
Code:
while read a b c d e f g
do
    if [ "$f" == "SU" ]
    then
        continue
    elif [ "$f" == "IN" ]
    then
        jd $a
    fi
done < inputfile

# 3  
Old 07-24-2012
Code:
 
awk '$6~/^IN$/{print $1}' input.txt | while read jobname; do jd $jobname;done

# 4  
Old 07-24-2012
Code:
awk '$6=="IN" {system("jd " $1 " >> /some/directory/logfile")}' inputfile


Last edited by elixir_sinari; 07-24-2012 at 08:05 AM..
# 5  
Old 07-24-2012
HI Thanks for the replies;Really they are great .I got a problem .I have autosys installed on my server and running.Now in the script when i write the command Jd job_name ,it is saying jd is invalid command .But if I gove the same command in the command prompt it is giving the result .can you shed some light and advise ?
# 6  
Old 07-24-2012
use the below command, instead of jd

Code:
 
awk '$6~/^IN$/{print $1}' input.txt | while read jobname; do autorep -q -J $jobname;done

# 7  
Old 07-24-2012
Hi Thanks for the reply .
autorep -q -J is equivalent of JR commnad in autosys.
the correct commad we should use is jd job_depends -c -w -j job_name .


Code:
af      autorep -Jfi_ude%box|grep FA
aj      (autorep -Jfi_ude%box)
aq      (autorep -q -J)
cjs     (sendevent -ECHANGE_STATUS -sSUCCESS -J)
cls     clear
ct      /usr/atria/bin/cleartool
fsj     (sendevent -EFORCE_STARTJOB -J)
h       history
home    (cd /itf/ude)
ia      sendevent -eCHANGE_STATUS -sINACTIVE -J
jd      job_depends -c -w -j
jh      sendevent -E JOB_ON_HOLD -J
joh     sendevent -E JOB_OFF_HOLD -J
jr      autorep -w -J
jw      /itf/ude/jobwatch.csh
kj      (sendevent -EKILLJOB -J)
ll      ls -lga
lsd     ls -lga | grep drw
ltr     ls -ltr
mr      (autorep -M)
se      (sendevent -E)
sj      (sendevent -E STARTJOB -J)

Again many thanks for ur reply.


Moderator's Comments:
Mod Comment Please use code tags next time for your code and data.

Last edited by zaxxon; 07-24-2012 at 09:28 AM.. Reason: code tags
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Problem with getting awk to multiply a field by a value set based on condition of another field

Hi, So awk is driving me crazy on this one. I have searched everywhere and read man, docs and every related post Google can find and still no luck. The actual files I need to run this on are sensitive in nature, but it is the same thing as if I needed to calculate weighted grades for multiple... (15 Replies)
Discussion started by: cotilloe
15 Replies

2. Shell Programming and Scripting

awk to update field using matching value in file1 and substring in field in file2

In the awk below I am trying to set/update the value of $14 in file2 in bold, using the matching NM_ in $12 or $9 in file2 with the NM_ in $2 of file1. The lengths of $9 and $12 can be variable but what is consistent is the start pattern will always be NM_ and the end pattern is always ;... (2 Replies)
Discussion started by: cmccabe
2 Replies

3. Shell Programming and Scripting

awk to adjust coordinates in field based on sequential numbers in another field

I am trying to output a tab-delimited result that uses the data from a tab-delimited file to combine and subtract specific lines. If $4 matches in each line then the first matching sequential $6 value is added to $2, unless the value is 1, then the original $2 is used (like in the case of line... (3 Replies)
Discussion started by: cmccabe
3 Replies

4. Shell Programming and Scripting

awk to parse field and include the text of 1 pipe in field 4

I am trying to parse the input in awk to include the |gc= in $4 but am not able to. The below is close: awk so far: awk '{sub(/\|]+]++/, ""); print }' input.txt Input chr1 955543 955763 AGRN-6|pr=2|gc=75 0 + chr1 957571 957852 AGRN-7|pr=3|gc=61.2 0 + chr1 970621 ... (7 Replies)
Discussion started by: cmccabe
7 Replies

5. Shell Programming and Scripting

Display combination of 4 field uniqe record and along with concatenate 5th and 6th field.

Table ACN|NAME|CITY|CTY|NO1|NO2 115|AKKK|ASH|IND|10|15 115|AKKK|ASH|IND|20|20 115|AKKK|ASH|IND|30|35 115|AKKK|ASH|IND|30|35 112|ABC|FL|USA|15|15 112|ABC|FL|USA|25|20 112|ABC|FL|USA|25|45 i have written shell script using cut command and awk programming getting error correct it and add... (5 Replies)
Discussion started by: udhal
5 Replies

6. Shell Programming and Scripting

Command/script to match a field and print the next field of each line in a file.

Hello, I have a text file in the below format: Source Destination State Lag Status CQA02W2K12pl:D:\CAQA ... (10 Replies)
Discussion started by: pocodot
10 Replies

7. Linux

How do I format a Date field of a .CSV file with multiple commas in a string field?

I have a .CSV file (file.csv) whose data are all enclosed in double quotes. Sample format of the file is as below: column1,column2,column3,column4,column5,column6, column7, Column8, Column9, Column10 "12","B000QRIGJ4","4432","string with quotes, and with a comma, and colon: in... (3 Replies)
Discussion started by: dhruuv369
3 Replies

8. Shell Programming and Scripting

AWK: Pattern match between 2 files, then compare a field in file1 as > or < field in file2

First, thanks for the help in previous posts... couldn't have gotten where I am now without it! So here is what I have, I use AWK to match $1 and $2 as 1 string in file1 to $1 and $2 as 1 string in file2. Now I'm wondering if I can extend this AWK command to incorporate the following: If $1... (4 Replies)
Discussion started by: right_coaster
4 Replies

9. Shell Programming and Scripting

awk, comma as field separator and text inside double quotes as a field.

Hi, all I need to get fields in a line that are separated by commas, some of the fields are enclosed with double quotes, and they are supposed to be treated as a single field even if there are commas inside the quotes. sample input: for this line, 5 fields are supposed to be extracted, they... (8 Replies)
Discussion started by: kevintse
8 Replies

10. Shell Programming and Scripting

Sort alpha on 1st field, numerical on 2nd field (sci notation)

I want to sort alphabetically on the first field and sort in descending numerical order on the 2nd field. With a normal "sort -r -n" it does this: abc ||| 5e-05 ||| bla abc ||| 3 ||| ble def ||| 1 ||| abc def ||| 0.2 ||| def As you can see it ignores the fact that 5e-05 is actually 0.00005... (1 Reply)
Discussion started by: FrancoisCN
1 Replies
Login or Register to Ask a Question