Multiple if body how?


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Multiple if body how?
# 1  
Old 10-25-2011
Multiple if body how?

Hi All,

I'm a newbie here, I'm just wondering how can i print my two code in if statement?

Code:
 awk -F "," '{ if ($10 ="YES")
                print $1",",$2",",$4",",$5",",$6;}' $line > $line.dat -->this is working
                print $2",",$4}' $line > niks.txt --> i encountered error on this while i try to insert my second body print statement.

how can i insert my 2nd print inside the my if statement?

Please advise,

Thanks,
# 2  
Old 10-25-2011
Code:
awk -F "," '{ if ($10 ="YES")
                print $1",",$2",",$4",",$5",",$6 > $line.dat 
                print $2",",$4 > niks.txt }' $line

This User Gave Thanks to rdcwayx For This Post:
# 3  
Old 10-25-2011
Thank you Sir rdcwayx. i'm going to try it now.

---------- Post updated at 12:31 PM ---------- Previous update was at 12:24 PM ----------

Hi Sir,

it looks like there's a problem in a code. I encountered a syntax error.
Code:
print $1",",$2",",$4",",$5",",$6 > $line.dat
awk: cmd. line:1:                                                       ^ syntax error

my code
Code:
 awk -F "," '{ if ($10 ="ACT")
                print $1",",$2",",$4",",$5",",$6 > $line.dat
                print $2",",$4 > ${DIR}$line.ns }' $line

# 4  
Old 10-25-2011
Code:
awk  -F "," '{ if ($10 ="YES")
                      { print $1,$2,$4,$5,$6 > FILENAME ".dat" 
                         print $2,$4 > "niks.txt" }
             }' OFS=,  $line

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Advanced & Expert Users

Mutt for html body and multiple html & pdf attachments

Hi all: Been racking my brain on this for the last couple of days and what has been most frustrating is that this is the last piece I need to complete a project. There are numerous posts discussing mutt in this forum and others but I have been unable to find similar issues. Running with... (1 Reply)
Discussion started by: raggmopp
1 Replies

2. Shell Programming and Scripting

Mail with body

Hello All, I wish to mail after completion of code. I would like to include subject and body in it. I am not looking to read the body from other file but willing to provide the body in the command itself. Can i do this way? I am looking to pass some parameters to body and this will be possible... (1 Reply)
Discussion started by: forums123456
1 Replies

3. UNIX for Advanced & Expert Users

Email with multiple attachments & HTML body

I have a html file: # cat sample.html <html> <body> Sample HTML file</p> </body> </html> And I have two excel sheets (sheet1.xls & sheet2.xls) I want to send an email by having the sample.html as the message body and two spreadsheets as the attachments. I tried using the below command:... (12 Replies)
Discussion started by: BHM
12 Replies

4. Shell Programming and Scripting

Any body suggest me.........!!!!

i am jaswanth, i am very new to unix/linux, upto now i worked in windows only., but i took coatching for unix.., and my sir teached all my classes in red hat linux and told me that all are same...!!! I know shall programming in red hat linux.., but now i installed opensloaris but the... (5 Replies)
Discussion started by: strgraphics
5 Replies

5. Shell Programming and Scripting

how to send jpg as body

Hi, I ftp the .jpg file from windows to unix machine, now i need to send the jpg file as body to (not as attachment) outlook, can anyone send the sample code for this? (1 Reply)
Discussion started by: vasu.g
1 Replies

6. Shell Programming and Scripting

How to mail with this body

Hi, i have a file ABC, i want to mail the contents of this file and i want to make the body of the mail per my choice like this: Hi All, This is the Report for today. <Browse of the File ABC> i am using : mailx -s "Today's Report" abcd@xyz.com << EOT Hi All, This is... (1 Reply)
Discussion started by: Prat007
1 Replies

7. Shell Programming and Scripting

how to check body of the email

Dears, i have user called dellsh i hope to make this script when this user recieve email check the budy of the email about (StatusRequest) when i find this email contain this subject run crontab do this job (create file in my home directory called index) thanks for your attention (1 Reply)
Discussion started by: dellsh
1 Replies

8. UNIX for Dummies Questions & Answers

can any body help me out on this...

Hi friends.. I am using the below command to search few files from many folders which is under one folder.. i mean let say the path is A/B/C...and inside C...i have 1-10 folder... the below command is working fine.... for i in 1 3 5 7; do find /A/B/C/${i} -name "*.txt" -o -name "*.csv"... (2 Replies)
Discussion started by: sapan123
2 Replies

9. Linux

Can any body tell me.

:(I want to install linux (SLES-9-SP4-CD-x86_64-GM-CD1) but it doesnot work. It said the computer is 32 bits you cannot use 64 bits on it. (3 Replies)
Discussion started by: sackNumchai
3 Replies

10. Shell Programming and Scripting

Can any body correct the code

#!/bin/ksh LOG_DATE=`date +%Y%m` export LOG_DATE cd D:/Informatica/Informatica_share/SrcFiles/l # mv SITE_ACTIVITY${LOG_DATE}*.CSV D:/Informatica/Informatica_share/SrcFiles/SITE_ACTIVITY${LOG_DATE}*.CSV # mv SITE_ACTIVITY20050914114546.CSV... (6 Replies)
Discussion started by: vivekanandarpat
6 Replies
Login or Register to Ask a Question