Hi,
How to check status of the files in the awk script
i am having two awk script in one bash script.Like
-BELOW is the exact structure of the script
script name: new.sh
--> Now in the above script i need use exit -1; for checkin the status
--> What happans while testing 2nd awk gives the final status always.
-->For example new.sh script use to check error records , if first awk means v1 has error status should be -1
if 2nd awk v2 has error then status should -1
--> If v1 has error and v2 doesnt have the status is 0 that means its not taking exit -1;
--> if v2 has error and v1 doesnt have then status is -1
--> I want to check the if any of the awk check error then status should be give as -1; if no error then status hould be 0
You would need to check the exit status code $? in the script after each awk program has run. It only has a range of 0 to 255, so -1 isn't a valid value.
Do you need to execute the 2nd awk if the 1st fails?
if not use exit 1 for errors, and try:
if you still want to execute 2nd awk if the 1st fails:
exit_code will be 1 if A or B fails and 2 if both fail (adjust logic as you need).
Last edited by Chubler_XL; 10-28-2010 at 11:35 PM..
Reason: Typos
Hi, As you said its ok ,but this is only one script . i am using two awk commands in one bash shell script. i am running script like
./script name.sh param1 param2
Here i am executing single script.
Now in this awk will work individually , after 1st awk over 2 nd will start to execute. Now i just wanted to know can i check status usinf if () condition.
like in 1st awk if error persent it will print error msg in 2nd awk also,
Now if 1st awk has error and 2nd awk dont then it should return staus as fail thant means it if i use echo $? on unix box it should give some value if no error present then after using echo $? it returns 0.
could you please give some solution for this.
or Shall put whole script for you referance.
Please reply,,
Hi,
I dont need message to be print over there, need to exit the script if the file has error. i am putting my script below.
-> if i execute the script if the file has error it will go to if(n!=v1) condition now i need whenever it will go to if condtion after process all it should exit.
-> for checking status i'll use echo $? if error in file then it will return some value if not then returns 0
my script
--> i need to use exit -1; in the script to abord the script .if i use exit -1 in if (n!=v1) it will work for one record only if in file more than 2 rows having error then it wont work. Could you plz reply on that.
Thanks,
Ganesh.
Last edited by Franklin52; 10-29-2010 at 09:00 AM..
Reason: Please use code tags
Hello guys i have following problem. I'm trying to copy content of one file and paste this content in all .txt files in directory, but at line 15. My script copy the content at first line, not 15. I'm confused how to do this. Thank you in advance for your help!
This is my script:
ARGS=2 ... (9 Replies)
Hi,
I have two files
Hi,
I have two files
file1 :>
Code:
val="10" port="localhost:8080"httpadd="http:\\192.168.0.239"
file2 :>
Code:
val=${val} val="pdssx" port=${port}port="1324"httpadd=${httpadd}httpadd="raamraav"fileloc=${fileloc}
file3(or file2) should have following... (1 Reply)
Hi ,
I am having two files FILE1 and FILE2 as shown below
I need to search each and every element of Coulumn1 in the FILE1 in FILE2 and Globally replace with the Corresponding element of the Column2 in the FILE2 , For example and1 which is the first element of COl 1 of the FILE1 should be... (4 Replies)
Hi,
I have one csv file with 3 fileds like
tmp1.csv
2079|2010Aug|cardilogy
2349|2010Aug|numerology
2213|2010Aug|immunlogy
another csv file with code for those specialities
spec.csv
cardiology|CRD
numerology|NMY
immunology|IMY
i want to replace the contents of file 1 with codes... (2 Replies)
hello,
first, yes i searched the forum , google and read many tutorials but still have a problem with my script.
I have great Problems, because i haven't worked with regular expressions before and never had anything to do with shellscripts. i am a complete Newby in this sort of theme.
I have... (8 Replies)
Hi All,
I have the following input data:
That I'd like to look like this ($2 is the column I'd like it to appear in) where the entries are grouped by date:
The code I have at present is:
awk 'BEGIN {}
{
dt = $1
if (dt == dt_prev) {
pp = $3
... (7 Replies)
Hi
I am having some contents in my file like this
file1
##########################
pin (PIN1) {
direction : input ;
capacitance : 121 ;
max_transition : 231 ;
}
pin (PIN2) {
direction : input ;
capacitance : 124 ;
max_transition : 421 ;... (8 Replies)
Hi
Can anyone help me in this Problem
File1
#########################
HOLI 123 AND ONE TWO THREE AMITABH SAMSUNG
POLI AND TWO SENSE CRYING WING
PPIN TBFLAG I B AND OROLE TB_HOT=" DCT" TB_CAT=" CAT" TC_NOT=" AND"
+PIN TB=" HOT" TB_GATE=" KOT" TB_LATE=" MAT" TC=LOT
MAT DAT SAT... (5 Replies)
I wrote a awk but doesnt work as expected.
The Input File
attached input file
My awk Script
/^.......*EXEC CICS /,/END-EXEC/
{
if ( $0 ~ / LINK / )
{ tsflag=1 }
if ( $0 ~ /EXEC CICS/ && tsflag == 1 )
... (6 Replies)