Sponsored Content
Top Forums Shell Programming and Scripting Writing if condition in shell script and failing to do requirement Post 302898798 by Makarand Dodmis on Thursday 24th of April 2014 04:48:13 AM
Old 04-24-2014
Code:
       flag=0
       for file in $(cat con);
        do
                field=`echo $file | awk 'BEGIN { FS = "=" } { print $1 }'`
                val=`echo $file | awk 'BEGIN { FS = "=" } { print $2 }'`
                        if [ $field = "ABC" ] && [ $val -ge 123 ]; then
                               echo $field"="$val >> con2
                               flag=1
                        elif [ $field = "ABC" ] && [ $val -lt 123 ]; then
                                echo $field"=123" >> con2
                                flag=1
                        elif [ $field != "ABC" ]; then
                                echo $field"="$val >> con2
                        fi
        done

                        if [ $flag -eq 0 ]; then
                                echo "ABC=123" >> con2
                        fi
                cat con2 > con
                rm con2

 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Need help for writing shell script

Hello ALL, I am fresher in Unix . i need help to write small shell script . Please help me unix guru. I am developing the internal site in my office . the data files are generated in one directory everyday . I have to write shell script to sort those files and put it is internal site . ... (3 Replies)
Discussion started by: deepa20
3 Replies

2. AIX

Difference between writing Unix Shell script and AIX Shell Scripts

Hi, Please give me the detailed Differences between writing Unix Shell script and AIX Shell Scripts. Thanks in advance..... (0 Replies)
Discussion started by: haroonec
0 Replies

3. Shell Programming and Scripting

IF condition failing in a SSH script

Hi, I'm ssh-in to a remote machine (ubuntu) and trying to execute a little script in there.The script looks like this: ssh user@ubuntu <<EOF cd ~/test ls -l echo "Continue counting files starting with a`s ?" read answer if then ls -l a* else exit fi EOF Now everything works... (9 Replies)
Discussion started by: rubionis
9 Replies

4. Shell Programming and Scripting

Required Shell script for My requirement

Hi All, I joined today in this forum to have all of your help. I have a Big requirement, pls. help me to resolve. I'm using HP-UX 11.23. I need a shell script for the following requirement. I have a file (nodes.txt) that contains 1000 nodes. I'm running the following command:... (3 Replies)
Discussion started by: ntgobinath
3 Replies

5. UNIX for Advanced & Expert Users

Shell script failing to read large Xml record-urgent critical help

Hi All, I have shell script running on AIX 5.3 box. It has 7 to 8 "sed" commands piped(|) together. It has a an Xml file as its input which has many records internally. There are certain record which which have more than hundered tags.The script is taking a huge amount of time more than 1.5 hrs... (10 Replies)
Discussion started by: aixjadoo
10 Replies

6. Shell Programming and Scripting

Writing to file failing (maybe due to lock?)

Driver script kicks off supporter scripts in background. The supporter script writes it's own PID ($$) into a status file. When script completes, deletes the PID from the status file. The driver script constantly polls this status file for number of lines. As and when it's get lower than XX... (2 Replies)
Discussion started by: baivab
2 Replies

7. Shell Programming and Scripting

Unix commands failing inside the shell script

When my script deals with large input files like 22Gb or 18 GB the basic commands like sort or join fails when run from inside the shell scripts. Can there be any specific reason for this? For e.g. sort -u -t "," -k1,1 a.csv > a.csv.uniq" sort -u -t "," -k1,1 b.csv > b.csv.uniq" The... (3 Replies)
Discussion started by: esha
3 Replies

8. UNIX for Dummies Questions & Answers

Need help writing shell script!

Hi, I'm very new to this, so bear with me please. I want to write a sh script (or if there's a better format please let me know) that allows me to, when I run it, print the date to a file (1.out) take 2 arguments (files a.fa and b.fa), run them with another program, outputting to 2.out, and then... (4 Replies)
Discussion started by: ShiGua
4 Replies

9. Shell Programming and Scripting

How to write bash shell script for mentioned requirement?

Hi All, I am unable to write the script for the below requirement. Requirement: Main table dir_ancillary table contain three column "dir_ancillary.table_name"," dir_ancillary.text_file_name ", "dir_ancillary.Include" . This dir_ancillary contain undefined tables in the column... (2 Replies)
Discussion started by: Vineeta Nigam
2 Replies

10. Shell Programming and Scripting

Sybase connection failing through shell script

Hi All, I'm trying to connect to Sybase via shell script. i'm getting the following error. Please let me know where i'm going wrong. Note that i'm not having this issue when connecting via terminal. #!/usr/bin/bash SYBASE=/usr/sybase ISQL=$SYBASE/bin/isql export SYBASE ISQL ... (6 Replies)
Discussion started by: Irishboy24
6 Replies
GENLIB_WIRE1.3(October 1, 1997) 										   GENLIB_WIRE1.3(October 1, 1997)

NAME
GENLIB_WIRE1 - place a physical segment in the current figure SYNOPSYS
#include <genlib.h> void GENLIB_WIRE1(layer, width, ins1, con1, index1, ins2, con2, index2) char layer; long width; char *ins1, *con1, *ins2, *con2; ORIGIN
This software belongs to the ALLIANCE CAD SYSTEM developed by the ASIM team at LIP6 laboratory of Universite Pierre et Marie CURIE, in Paris, France. Web : http://asim.lip6.fr/recherche/alliance/ E-mail : alliance-users@asim.lip6.fr PARAMETERS
layer Layout layer of the segment width Width of the segment ins1 Name of the instance in which the connector con1 is to be looked for con1 Name of a connector, or reference, used as first endpoint of the wire ins2 Name of the instance in which the connector con2 is to be looked for con2 Name of a connector, or reference, used as last endpoint of the wire DESCRIPTION
WIRE1 adds a segment made of the layer level in the current layout cell, the starting point beeing the connector, or reference, con1 of the instance ins1, and the ending point beeing the connector, or reference, con2 of the instance ins1. The segment is drawn between the coordi- nates of con1 in the current figure and the coordinates of con2 in the current figure. If the endpoints are connectors, the indexes index1 and index2 must respectivly refer to con1 and con2. If they are references, then they are not taked care of. One shall notice that connectors and references of a given model should not share names if WIRE1 is to be used. The layer argument can take the following legal values : NWELL PWELL NTIE PTIE NDIF PDIF NTRANS PTRANS POLY ALU1 ALU2 ALU3 TPOLY TALU1 TALU2 TALU3 ERRORS
"GENLIB_WIRE1 impossible : missing GENLIB_DEF_PHFIG" No figure has been yet specified by a call to DEF_PHFIG. So it isn't possible to place an instance inside it. you must call DEF_PHFIG before any other layout action. "illegal addphseg : x1, y1, x2, y2" A symbolic segment must be either vertical or horizontal, so either x1 = x2, or y1 = y2. Since WIRE1 creates a segment from relative coordinates, care must be taken to follow the previous rule. "GENLIB_WIRE1 impossible : same name conX, for connector and reference in insX" The model of the instance insX has both a connector and a reference that matches the conX name. This is not legal since genlib doesn't know which one to choose as point. "illegal getphins : instance insX does not exist" The instance called insX does not currently belong to the figure. EXAMPLE
#include <genlib.h> main() { /* Create a figure to work on */ GENLIB_DEF_PHFIG("cell"); GENLIB_PLACE("gaci0_b", "r_addin_1", NOSYM, 0, 0); GENLIB_PLACE_RIGHT("gapgn_b", "pg", NOSYM); GENLIB_PLACE_RIGHT("gacin_b", "r_addin_2", NOSYM); /* Draw a segment */ GENLIB_WIRE1(ALU1, 1, "r_addin_1", "out", 0L, "r_addin_2", "in", 1L); /* Save that on disk */ GENLIB_SAVE_PHFIG(); } SEE ALSO
genlib(1), GENLIB_DEF_PHFIG(3), GENLIB_SAVE_PHFIG(3), GENLIB_COPY_UP_SEG(3), GENLIB_PHSEG(3), GENLIB_THRU_H(3), GENLIB_THRU_CON_H(3), GEN- LIB_THRU_V(3), GENLIB_THRU_CON_V(3), GENLIB_WIRE2(3), GENLIB_WIRE3(3). BUG REPORT
This tool is under development at the ASIM department of the LIP6 laboratory. We need your feedback to improve documentation and tools. PROCEDURAL GENERATION LANGUAGE
ASIM/LIP6 GENLIB_WIRE1.3(October 1, 1997)
All times are GMT -4. The time now is 08:30 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy