Sponsored Content
Top Forums Shell Programming and Scripting Awk+colpos+negative if for 20 values Post 302908401 by rajubollas on Monday 7th of July 2014 03:01:58 PM
Old 07-07-2014
Awk+colpos+negative if for 20 values

Hi All,

i have 20 Obligors when ever i dont find all of them on particular row/line from each in put i need to print it in different file.

using below command but it is not working please help at earliest.

Steps:
Code:
        set -A FILENAME   $( cat $config_file_path/crt_extracts_branch_gswid_cntl | grep -v "^#" | awk '{ print $1 }')
        set -A COLPOS     $( cat $config_file_path/crt_extracts_branch_gswid_cntl | grep -v "^#" | awk '{ print $4 }')

Code:
#Carrs Extract File                                             Column Position     Control File column position	GSWID Column Possition
##############################################################################################################################################
Assessment_Extract.txt                                       4                     0-17					3

Code:
$ cat GERMANY_Obligor_filter_ctl
##Obligor information file
##For new obligor for search contion add "|| $colpos != xxxxxx" in format
##make sure all condition values in single line
$colpos  != 228070 || $colpos  != 228071 || $colpos  != 228072 || $colpos  != 228073 || $colpos  != 228074 || $colpos  != 228075 || $colpos  != 228076 || $colpos  != 228077 || $colpos  != 228078 || $colpos  != 228079 || $colpos  != 228080 || $colpos  != 228081 || $colpos  != 228082 || $colpos  != 228083 || $colpos  != 228084 || $colpos  != 228085 || $colpos  != 228086 || $colpos  != 228196 || $colpos  != 228199$


ifcondition_val=$( grep -v "^#" $config_file_path/GERMANY_Obligor_filter_ctl)

command_construction=$( echo "cat \$SOURCE_DIR/\${FILENAME[\$x]}  | awk -F\"|\" -v colpos=\"\${COLPOS[\$x]}\"  'if (\"\$ifcondition_val\") { print \$0 }'  > \$NEWFILENAME")

eval $command_construction

please help me how to achieve it. i am trying to assign values dynamically. how to compare column position value in "if then else" dynamically?

Last edited by Scrutinizer; 07-07-2014 at 04:35 PM.. Reason: CODE tags
 

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Help in adding positive & negative values in a column

Hi Gurus, In my file I have an amount field from position 74 to 87, which contains values starting with '+' as well as '-'. I want to add all positive values in a varible called "CREDIT" and all negative values in a variable "DEBIT". I know, we can use grep to identify values with positive and... (4 Replies)
Discussion started by: berlin_germany
4 Replies

2. Shell Programming and Scripting

printf in bash shell not printing negative values

hi i am using printf in a script and it is not printing negative values..i have to use printf to get rid of the newline..here is my code: fin=`echo $a - $b | bc` printf "${fin}," >> test these statements are in a loop. here is what i get when i try to subtract 4 from 8: ./scr1: line... (2 Replies)
Discussion started by: npatwardhan
2 Replies

3. Shell Programming and Scripting

Sorting positive and negative values

Hello, I have a list like this : 1 2 -4 0 -3 -7 5 6 etc. Is there a way to remove all the positive values and print only the negative values, without using grep, sed or awk? Thanks, Prasanna (4 Replies)
Discussion started by: prasanna1157
4 Replies

4. Shell Programming and Scripting

Find Where Values Change From Positive To Negative and viceversa

Hi all, I have a file that looks like shown below. I want to find places where the value in column 2 change from negative to positive and vice versa and return the value on column 1 at that point. I wonder if this is possible in shell script or awk .. please help! Here is the original data ... (6 Replies)
Discussion started by: malandisa
6 Replies

5. UNIX for Dummies Questions & Answers

Snmp Disk Problem = Negative Values

Ok, so i monitor disk space on remote machines using snmp. Works great for me. But whenever a particular partition happens to have Terabytes of data, snmp starts reporting negative values. Can someone please tell me how to get around this problem? The AllocationUnit is 512 bytes. Weird... (0 Replies)
Discussion started by: SkySmart
0 Replies

6. Shell Programming and Scripting

error- multiplying negative decimal values

a=10.02 pattern=-11.01 b=$(echo | awk '{ print $a*$pattern}') echo $b its not working even ALso tried `expr $a \* $pattern` No LUCK (3 Replies)
Discussion started by: saluja.deepak
3 Replies

7. Shell Programming and Scripting

replacing negative values in a column with zero

Hi, i need help on replacing negative values in a column with 0. any quick fix on this? thanks much. for instance, input: 1 2.3 -0.4 -25 12 13 45 -12 desired output 1 2.3 0 0 12 13 45 (4 Replies)
Discussion started by: ida1215
4 Replies

8. Shell Programming and Scripting

Conavert negative values to Zeros

Can anyone please assist me? Please find the attached input and output file for ur reference. a)Incase if i get negative value (ex:-000100) in the 11th column then i have to convert the value to 0000000(7 zeros-length is 7) and then print the entire record. b)Incase if there is no... (2 Replies)
Discussion started by: vinus
2 Replies

9. Shell Programming and Scripting

How to sum the value with negative values?

Hi Gurus, I have requirement need to sum the value, the logic is if the value is negative then time -1, I tried below two ways. one is failed, another one doesn't work. awk -F"," '{if($8< 0 $8*-1 else $8) sum+=$8}{print sum, $8} END{printf("%.2f\n",sum)}' awk -F","... (4 Replies)
Discussion started by: ken6503
4 Replies
HOBBIT-STATUSREPORT.CGI(1)				      General Commands Manual					HOBBIT-STATUSREPORT.CGI(1)

NAME
hobbit-statusreport.cgi - CGI program to report a status for a group of servers SYNOPSIS
hobbit-statusreport.cgi --column=COLUMNNAME [options] DESCRIPTION
hobbit-statusreport.cgi is a CGI tool to generate a simple HTML report showing the current status of a single column for a group of Xymon hosts. E.g. You can use this report to get an overview of all of the SSL certificates that are about to expire. The generated webpage is a simple HTML table, suitable for copying into other documents or e-mail. hobbit-statusreport.cgi runs as a CGI program, invoked by your webserver. It is normally run via a wrapper shell-script in the CGI direc- tory for Xymon. EXAMPLES
The Xymon installation includes two web report scripts using this CGI tool: The hobbit-certreport.sh script generates a list of SSL server certificates that are yellow or red (i.e. they will expire soon); and the hobbit-nongreen.sh script generates a report of all statuses that are currently non-green. These can be accessed from a web browser through a URL referencing the script in the Xymon CGI directory (e.g. "/xymon-cgi/xymon-nongreen.sh"). OPTIONS
--column=COLUMNNAME Report the status of the COLUMNNAME column. --all Report the status for all hosts known to Xymon. By default, this tool reports only on the hosts found on the current page from where the CGI was invoked (by looking at the "pagepath" cookie). --filter=CRITERIA Only report on statuses that match the CRITERIA setting. See the bb(1) man-page - in the "hobbitdboard" command description - for details about specifying filters. --heading=HTML Defines the webpage heading - i.e. the "title" tag in the generated HTML code. --show-column Include the column name in the display. --show-colors Show the status color on the generated webpage. The default is to not show the status color. --no-colors Do not include text showing the current color of each status in the report. This is the default. --show-summary Show only a summary of the important lines in the status message. By default, the entire status message appears in the generated HTML code. This option causes the first non-blank line of the status message to be shown, and also any lines beginning with "&COLOR" which is used by many status messages to point out lines of interest (non-green lines only, though). --show-message Show the entire message on the webpage. This is the default. --link Include HTML links to the host "info" page, and the status page. --embedded Only generate the HTML table, not a full webpage. This can be used to embed the status report into an external webpage. --env=FILENAME Load the environment from FILENAME before executing the CGI. --area=NAME Load environment variables for a specific area. NB: if used, this option must appear before any --env=FILENAME option. SEE ALSO
xymon(7) Xymon Version 4.2.3: 4 Feb 2009 HOBBIT-STATUSREPORT.CGI(1)
All times are GMT -4. The time now is 06:04 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy