UNIX for Dummies Questions & Answers

This forum is closed for new posts. Please post beginner questions to learn unix and learn linux in this forum UNIX for Beginners Questions & Answers

if statement in awk


Thread Tools Search this Thread Display Modes
Old 08-04-2009
UNovIX UNovIX is offline
Registered User
Join Date: Jul 2009
Last Activity: 11 August 2009, 3:31 PM EDT
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
if statement in awk

Hi Friends

How do I do two things from one if statement inside awk? I want to run a script and create a new file from the same condition.

awk '{ if ($2 == ""){print " "|"cd /local/test; ./script.ksh"}{cat > ran_true.txt}}' $IN_FILE

Bolded are the two things I want to be done.

Sponsored Links
Old 08-04-2009
jim mcnamara jim mcnamara is offline Forum Staff  
Join Date: Feb 2004
Last Activity: 20 July 2018, 10:42 AM EDT
Location: NM
Posts: 11,441
Thanks: 638
Thanked 1,176 Times in 1,082 Posts
awk '{ if ($2 == ""){print " "|"cd /local/test; ./script.ksh"; cat > ran_true.txt}}' $IN_FILE
# or
awk '{ if ($2 == ""){print " "|"cd /local/test; ./script.ksh"
                           cat > ran_true.txt}}' $IN_FILE

solaris: try nawk, not awk.
Sponsored Links

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
if statement ROOZ Shell Programming and Scripting 7 11-05-2008 09:02 PM
How is use sselect statement o/p in insert statement. nkosaraju Shell Programming and Scripting 2 08-06-2008 09:26 PM
IF Statement koti_rama Shell Programming and Scripting 3 04-29-2008 04:48 AM
If statement - How to write a null statement april Shell Programming and Scripting 3 04-16-2008 01:14 PM
If statement ROOZ UNIX for Dummies Questions & Answers 3 03-09-2008 12:57 PM

All times are GMT -4. The time now is 06:11 PM.

Unix & Linux Forums Content Copyrightę1993-2018. All Rights Reserved.
Show Password

Not a Forum Member?
Forgot Password?