Sponsored Content
Top Forums Shell Programming and Scripting Help a newbie please with awk if else statements Post 302244169 by otheus on Tuesday 7th of October 2008 10:53:30 AM
Old 10-07-2008
See the bolded remarks I put in the snippets of your code.

Quote:
Originally Posted by jonathanm
Code:
$36 ~ /N/ { for (i = 1; i<= NF; i++) {
   gsub(/^ /, "", $i);
   gsub(/ $/, "", $i);
   gsub(/"/, "", $i);
   }
  }
  ^-- this is (probably) wrong. You want to end the block below
output = ""
 
... 

 else if ( $55 ~ /Applicant/ && !$58 ) {
  output = sprintf("%s, %s %s %s %s", output, $60, $56, $57, $58, $59);
  }
 
}
^-- you need to finish the block here
 
END {  
  printf("%s\n",output);
  print "Finished!  Output sent to '"new_fname"'"
  }

 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

awk compound statements

how can i use two or multiple statements in the if part of an awk code for example i want to check two flag if they are true i will write some print operations and increase the counter. here is the c version of the code that i want to write: counter=0; if (flag1==1 && flag2==0) {... (7 Replies)
Discussion started by: gfhgfnhhn
7 Replies

2. Shell Programming and Scripting

Combine awk statements

I have an awk statement that works but I am calling awk twice and I know there has to be a way to combine the two statements into one. The purpose is to pull out just the ip address from loopback1. cat config.txt | nawk 'BEGIN {FS="\n"}{RS="!"}{if ( $0 ~ "interface loopback1" ) print$4}' | nawk... (5 Replies)
Discussion started by: numele
5 Replies

3. Shell Programming and Scripting

Combining awk statements

I have a pretty simple script below: #!/bin/sh for i in *.cfg do temp=`awk '/^InputDirectory=/' ${i}` input_dir=`echo ${temp} | awk '{ print substr( $0, 16) }'` echo ${input_dir} done As you can see its opening each cfg file and searching for the line that has "InputDirectory="... (3 Replies)
Discussion started by: ssbsts
3 Replies

4. Shell Programming and Scripting

Combining AWK statements

Hello UNIX Community, I have file that contains the following data: testAwk2.csv rabbit penguin goat giraffe emu ostrich hyena elephant panda dog cat pig lizard snake antelope platypus tiger cheetah lion rhino spider I then find the character length of the... (1 Reply)
Discussion started by: vnayak
1 Replies

5. UNIX for Dummies Questions & Answers

AWK w/ if statements failing.

I'm converting some code from ksh on my macbook (Version M 1993-12-28 s+) to an older solaris machine with ksh 88. I can't seem to figure out this line, it worked on the new shell version. set -A combo -- $(for x in ${ImageIDs}; do nawk -v s=$x 'if($2 == s) getline ; getline if ($1 ==... (2 Replies)
Discussion started by: nerdcurious
2 Replies

6. Shell Programming and Scripting

How to use awk or nawk by using Conditional Statements

Hi Guys! Anybody know how can I use a nawk or awk on a script and printing the NAME, SECTION (must be 410 or 411 or 414) and TOTAL COST of CLASS 1 and 3 combined must be greater than 50. See below desired output file. input.txt: NAME,CLASS,COST,SECTION JOHN,1,10,410 JOHN,2,20,410... (2 Replies)
Discussion started by: pinpe
2 Replies

7. UNIX for Dummies Questions & Answers

Combine two awk statements into one

Hi, I have the following two awk statements which I'd like to consolidate into one by piping the output from the first into the second awk statement (rather than having to write kat.txt out to a file and then reading back in). awk 'BEGIN {FS=OFS=" "} {printf("%s ", $2);for (x=7; x<=10;... (3 Replies)
Discussion started by: kasan0
3 Replies

8. Shell Programming and Scripting

awk problem - combining awk statements

i have a datafile that has several lines that look like this: 2,dataflow,Sun Mar 17 16:50:01 2013,1363539001,2990,excelsheet,660,mortar,660,4 using the following command: awk -F, '{$3=strftime("%a %b %d %T %Y,%s",$3)}1' OFS=, $DATAFILE | egrep -v "\-OLDISSUES," | ${AWK} "/${MONTH} ${DAY}... (7 Replies)
Discussion started by: SkySmart
7 Replies

9. Shell Programming and Scripting

Nested awk Statements

Hello again everyone, yes, I'm back again for more help! So I'm attempting to read two separate files and generate some XML code from that. My current code is: BEGIN { print "<?xml version=\"1.0\" encoding=\"utf-8\">" print "<Export>" } { x=1; print "<section name=\"Query" NR "\">"... (5 Replies)
Discussion started by: Parrakarry
5 Replies

10. Shell Programming and Scripting

awk with many if statements

Hi What is the right structure to use awk with multiple If statements The following code doesn't work # awk ' { A = $1 } END { for ( i = 1; i <= c; i++ ) { if ( A == 236 && A ==199... (7 Replies)
Discussion started by: khaled79
7 Replies
DH_INSTALLCATALOGS(1)						     Debhelper						     DH_INSTALLCATALOGS(1)

NAME
dh_installcatalogs - install and register SGML Catalogs SYNOPSIS
dh_installcatalogs [debhelperoptions] [-n] DESCRIPTION
dh_installcatalogs is a debhelper program that installs and registers SGML catalogs. It complies with the Debian XML/SGML policy. Catalogs will be registered in a supercatalog, in /etc/sgml/package.cat. This command automatically adds maintainer script snippets for registering and unregistering the catalogs and supercatalogs (unless -n is used). These snippets are inserted into the maintainer scripts by dh_installdeb; see dh_installdeb(1) for an explanation of Debhelper maintainer script snippets. A dependency on sgml-base will be added to ${misc:Depends}, so be sure your package uses that variable in debian/control. FILES
debian/package.sgmlcatalogs Lists the catalogs to be installed per package. Each line in that file should be of the form "source dest", where source indicates where the catalog resides in the source tree, and dest indicates the destination location for the catalog under the package build area. dest should start with /usr/share/sgml/. OPTIONS
-n, --noscripts Do not modify postinst/postrm/prerm scripts. NOTES
Note that this command is not idempotent. dh_prep(1) should be called between invocations of this command. Otherwise, it may cause multiple instances of the same text to be added to maintainer scripts. SEE ALSO
debhelper(7) /usr/share/doc/sgml-base-doc/ AUTHOR
Adam Di Carlo <aph@debian.org> 8.9.0ubuntu2.1 2012-06-12 DH_INSTALLCATALOGS(1)
All times are GMT -4. The time now is 08:54 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy