Help with for/if/else print statements


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Help with for/if/else print statements
# 1  
Old 03-14-2012
Help with for/if/else print statements

Code:
{for(i in b){if(b[i]-1&&a[i]!=b[i]){print i";\t\t"b[i]}else{print "NEW:"i";\t\t"b[i]} } }

what I need is to just print

Code:
else{print "NEW:"i";\t\t"b[i]

and not print

Code:
{print i";\t\t"b[i]}

how do i get awk to not print the first bit? is there an ignore statement although i still need awk to use this statement for the calculation in

Code:
else{print "NEW:"i";\t\t"b[i]

if you understand the logic
# 2  
Old 03-14-2012
Just remove the code from the fist part:
Code:
{for(i in b){if(b[i]-1&&a[i]!=b[i]){}else{print "NEW:"i";\t\t"b[i]} } }

This User Gave Thanks to bartus11 For This Post:
# 3  
Old 03-14-2012
great it works, I was missing the

Code:
{}

---------- Post updated at 08:56 PM ---------- Previous update was at 08:55 PM ----------

any chance you could answer my other post

https://www.unix.com/shell-programmin...uirements.html
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Generate print statements

I need to pickup values provided in braces from a file with many records I am able to get the count of number of dept's in each line .How do we write a logic to generate a print statement like below instead of using a while loop if the count is 0 it should generate awk -F'' '{print $2 }' ... (1 Reply)
Discussion started by: llazydev
1 Replies

2. Shell Programming and Scripting

Quick and easy way to comment out multi lined print statements

Is there a quick and easy way to comment out multi lined print statements? something like this? printf("3408 strings_line_tokens %s \n", strings_line_tokens); (6 Replies)
Discussion started by: cokedude
6 Replies

3. Shell Programming and Scripting

Sftp : not able to print the echo statements after the sftp transfer

I had the below sftp script working perfectly but the problem is I am not able to send the echo statements . #!/bin/sh echo "Starting to sftp..." sftp admin@myip << END_SCRIPT cd /remotepath/ lcd /localpath/ mget myfiles*.csv bye END_SCRIPT echo "Sftp successfully." echo echo... (11 Replies)
Discussion started by: scriptscript
11 Replies

4. UNIX for Dummies Questions & Answers

if and then statements

I came across a bash script that outputs the forecast for the day and the max temperature but at the end of the day the max temperature disappears ($6) and I am left with "°C" after the forecast. Here is the script: #! /bin/bash curl -s --connect-timeout 30... (7 Replies)
Discussion started by: _light_
7 Replies

5. Homework & Coursework Questions

Using While and If statements

1. The problem statement, all variables and given/known data: Two problems I need solving please. I created a script where the user types in 7 numbers as standard input and each one is then stored in an array. Now I need to perform the following calculations on those numbers: 1) Use a while... (11 Replies)
Discussion started by: jjb1989
11 Replies

6. Shell Programming and Scripting

vi and if statements

Hi I am very new to Unix programming and shell scripting. I am trying t figure out how to write a little script that will output the number of directories. I can find the number of directories using ls -l | grep "^d" | wc -l I can not figure out how to do it so when I type the name... (8 Replies)
Discussion started by: Reddoug
8 Replies

7. UNIX for Dummies Questions & Answers

Help with For Statements

Hi, I am trying to write a for statement that will allow for the ps, who, finger, and date commands to run. Can anyone help? I use Putty. (22 Replies)
Discussion started by: lexydoll87
22 Replies

8. Shell Programming and Scripting

HELP!! if statements

I am kind of new in Unix and i have to make a menu. I want to put an if statement in the menu. you should enter the filename and it goes to that file. How do i do this? (1 Reply)
Discussion started by: trob
1 Replies

9. UNIX for Advanced & Expert Users

if statements

This is for a program I have to do to calculate the day of the week. I need to write an if statement that will do the following: if day is 29 and year is odd, don't calculate dayif ( day == 29 && year == ??? )I know how to do it for the day but I don't know how to do it for the year. (4 Replies)
Discussion started by: pwanda
4 Replies

10. Shell Programming and Scripting

Please help on IF statements.

I had different problem scenarios with IF statement. Can any expert please enlighten me on the difference with these scenarios. Thank you. 1st Scenario: testdate=`date +%Y%m` test=`cat /var/log/database0.$testdate*.log | grep "Errors found during processing" | tail -10` if then ... (4 Replies)
Discussion started by: filthymonk
4 Replies
Login or Register to Ask a Question