Sponsored Content
Top Forums Shell Programming and Scripting Execution Problem with awk command Post 302949027 by Shilpi Gupta on Monday 6th of July 2015 08:30:40 AM
Old 07-06-2015
Execution Problem with awk command

Hi All,

I am trying to find a word from a file in loop.

Code:
  
 while read i; do
  DB_Name=$i
  awk '{for(i=1;i<=NF;i++)if($i~/$DB_Name/)print $(i)}' $BTEQ_NAME > $DB_Name_TableList.txt
  done <Param.txt

here Param.txt contents data as
Code:
  
 ODS_TARGT_RECV
FIN_TARGT
ODS_TARGT
ODS_REP
ODS_REP_SRCE
ODS_ARCV
EDW_TARGT
EDW_REP
EDW_DATA
EDW_REP_SRCE
edw_etl_target
edw_archive
WEB_TARGT
edw_archive
WEB_DRG1_APP_SRCE

And $BTEQ_NAME is passed as BTQ_OAP_700_dI_OSTG_AP_INVC_FS.sh, In the main body.

Code:
  
 #Script Name : DB_Validation.sh
#Author : Shilpi Gupta
 clear
 DB_FIND()
 {
  IFS=$'\n' 
  set -f
  echo "=================$BTEQ_NAME=================="
  while read i; do
  DB_Name=$i
  awk '{for(i=1;i<=NF;i++)if($i~/$DB_Name/)print $(i)}' $BTEQ_NAME > $DB_Name_TableList.txt
  done <Param.txt
 
  
}
  
 # Main Body of this Script
 BTEQ_NAME_LIST=$1
BTEQ_PARAM_FILE=$2
 awk '{for(i=1;i<=NF;i++)if($i~/\=/)print $(i)}' $BTEQ_PARAM_FILE|cut -d"=" -f1 > ParamP1.txt
 awk '{for(i=1;i<=NF;i++)if($i~/_/)print $(i)}' ParamP1.txt > Param.txt
 rm ParamP1.txt
 awk '{for(i=1;i<=NF;i++)if($i~/\=/)print $(i)}' $BTEQ_PARAM_FILE|cut -d"=" -f2 > ParamVal1.txt
 awk '{for(i=1;i<=NF;i++)if($i~/_/)print $(i)}' ParamVal1.txt > ParamVal.txt
 rm ParamVal1.txt
 for i in `cat ${BTEQ_NAME_LIST}` ; do
BTEQ_NAME=`echo "${i}" | awk -F"|" '{ print $1 }'`;
export BTEQ_NAME;
 DB_FIND
done


But while executing the script getting error as:
Code:
  
 awk: can't open BTQ_OAP_700_dI_OSTG_AP_INVC_FS.sh
 :
 :

Please let me Know where I am doing wrong...

Thanks,

Shilpi Gupta

Last edited by vbe; 07-06-2015 at 09:51 AM.. Reason: extra code tags...
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

problem in awk command

Hello all, i am new one to this forum. : i have file with these contents.. internal://project/squid-internal-static/icons/anthony-xpm.gif http://widget.blogrush.com/img/br.png http://www.wingware.com/css/print http://publib.boulder.ibm.com/infocenter/systems/advanced/filterwarning.css... (3 Replies)
Discussion started by: viveksnv
3 Replies

2. Shell Programming and Scripting

Execution of awk command in a variable

Hi All, I have a awk command that is stored in a variable. the value of the variable cmd is: (mean output of echo $cmd is: ) awk -F";" '{print $1}' Now I want to execute this command. How can I do that???? Quick Reply will be appreciated. Regards, Amit (2 Replies)
Discussion started by: patelamit009
2 Replies

3. Post Here to Contact Site Administrators and Moderators

AWK command problem

How can I write an AWK so it could print some fixed strings and concatenate that with other words from an input file. Also having a string like "go" in the next line in the output file as below: Example: A fixed string like: "Hello my" and the input file is: friend mother father... (4 Replies)
Discussion started by: sybase08
4 Replies

4. Shell Programming and Scripting

Execution problems using awk command.

Hi All, I have the following requirement. In a directory i get files from external source. I at regular intervals check that directory for any incoming files. The file name is underscore delimited. Such as: aaa_bbb_ccc_ddd_eee_fff.dat I am using awk and and splitting the file name. ... (4 Replies)
Discussion started by: satishpv_2002
4 Replies

5. Shell Programming and Scripting

problem with awk command

I am having problem running an awk commad on a file Before applying awk command on the file After applying I don't expect more than 409743 records in the file. Why do I have 1 record more after applying awk command? Please let me know (4 Replies)
Discussion started by: dsravan
4 Replies

6. Shell Programming and Scripting

problem with awk command

I have written some code in a KSH script to find the index of the character in a string like this #!usr/bin/ksh string="Hi How are you" awk 'BEGIN {print index ($string, "are")}' My expected output should be : 8 but it is giving the out put as : 0 I wanted to store that index value in... (8 Replies)
Discussion started by: hemanth424
8 Replies

7. Shell Programming and Scripting

getting problem in awk command

Hi, I have one file with tab delimited values in it. i want to increase the value of 6th field by 2 if value of 3rd field is greater than 2 . The command is working fine but space between the field is getting removed after adding. below is the file and the command Filename: test1.txt ... (13 Replies)
Discussion started by: ravi_agarwalla
13 Replies

8. Linux

Execution problem wid mpstat command

mpstat -P ALL 1 10 it results.. 08:05:54 PM CPU %user %nice %sys %iowait %irq %soft %steal %idle intr/s 08:05:55 PM all 0.00 0.00 0.49 0.00 0.49 0.00 0.00 99.02 1024.75 08:05:55 PM 0 0.00 0.00 0.00 0.00 0.99 0.00 0.00 ... (1 Reply)
Discussion started by: pritesh_patil
1 Replies

9. Shell Programming and Scripting

Multiple command execution inside awk command during xml parsing

below is the output xml string from some other command and i will be parsing it using awk cat /tmp/alerts.xml <Alert id="10102" name="APP-DS-ds_ha-140018-componentFailure-S" alertDefinitionId="13982" resourceId="11427" ctime="1359453507621" fixed="false" reason="If Event/Log Level(ANY) and... (2 Replies)
Discussion started by: vivek d r
2 Replies

10. Shell Programming and Scripting

awk execution problem in csh

This has no error awk '($8==150) && ($4>=11.001 && $4 <= 12) && ($5>=91.001 && $5<=92){print}' OFS="\t" file following are unable to run in csh this is giving error awk: line 1: syntax error at or near not even working in terminal awk '($'$gr'=='$grn') && ($'$ll'>='$Y' && $'$ll' <= '$Ym')... (1 Reply)
Discussion started by: nex_asp
1 Replies
IGAWK(1)							 Utility Commands							  IGAWK(1)

NAME
igawk - gawk with include files SYNOPSIS
igawk [ all gawk options ] -f program-file [ -- ] file ... igawk [ all gawk options ] [ -- ] program-text file ... DESCRIPTION
Igawk is a simple shell script that adds the ability to have ``include files'' to gawk(1). AWK programs for igawk are the same as for gawk, except that, in addition, you may have lines like @include getopt.awk in your program to include the file getopt.awk from either the current directory or one of the other directories in the search path. OPTIONS
See gawk(1) for a full description of the AWK language and the options that gawk supports. EXAMPLES
cat << EOF > test.awk @include getopt.awk BEGIN { while (getopt(ARGC, ARGV, "am:q") != -1) ... } EOF igawk -f test.awk SEE ALSO
gawk(1) Effective AWK Programming, Edition 1.0, published by the Free Software Foundation, 1995. AUTHOR
Arnold Robbins (arnold@skeeve.com). Free Software Foundation Nov 3 1999 IGAWK(1)
All times are GMT -4. The time now is 07:19 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy