![]() |
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here. |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| how to read record by record from a file in unix | raoscb | UNIX for Dummies Questions & Answers | 1 | 05-16-2008 06:30 AM |
| If statement - How to write a null statement | april | Shell Programming and Scripting | 3 | 04-16-2008 01:14 PM |
| splitting a record and adding a record to a file | rsolap | Shell Programming and Scripting | 1 | 08-13-2007 01:58 PM |
| compare null with non-null | nitin | Shell Programming and Scripting | 8 | 11-04-2006 07:58 PM |
| How Many "Falling Unix Commands" are in the Flash Header? | Neo | Post Here to Contact Site Administrators and Moderators | 10 | 01-22-2004 02:47 PM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
If statement falling over on a null record. Help please.
Okay i've got some code which reads a text file and loops through it and there a few if statements inside where one is failing (the one bolded).
Basically the acc column contains a list of three digit access codes, some though have null records (i.e nothing in the field) so what I want to do is if its not null to carry on to the other loops if it is null to move on to the next record. I thought -n meant if the value is greater than 0 in length. I.e not null. When it gets the the first null record i get the following error message create_matrix_busy.exe: test: argument expected This is my code so far... while read line do sdate=`echo "$line" | cut -d, -f1` edate=`echo "$line" | cut -d, -f2` edate=`echo "$line" | cut -d, -f2` site=`echo "$line" | cut -d, -f3` NA=`echo "$line" | cut -d, -f4` acc=`echo "$line" | cut -d, -f6` calls=`echo "$line" | cut -d, -f8` if [ -n ${acc} ] then if [ ${calls} -gt 0 ] then if [ ${NA} = 'ALL' ] then echo ${site},${acc} elif [ ${NA} = 'NA*' ] then echo ${site},NA${acc} fi fi fi Thanks, the code will do more inside the if statements once i get those working. |
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|