Problem running awk script in Debian 6.0.2


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Problem running awk script in Debian 6.0.2
# 8  
Old 10-16-2012
try putting the script in a file and run it with 'awk -f myScriptFile myInputFile'.
make sure there are not ^M-s and/or other crumbs....
# 9  
Old 10-16-2012
Quote:
Originally Posted by Ophiuchus
bartus, I get this
Code:
$ gawk
-bash: gawk: command not found

---------- Post updated at 05:31 PM ---------- Previous update was at 05:24 PM ----------

If I go to:
Code:
/usr/bin

I see this:
Code:
lrwxrwxrwx 1 root   root         21 Dec 12  2008 awk -> /etc/alternatives/awk

any other awk-s under /usr/bin?
ls /usr/bin/*awk*
Or under /usr/local/bin ?
# 10  
Old 10-16-2012
Hello vgersh99,

Thank you for the help.

There is no other awk in /usr/bin/ and there is none in /usr/local/bin.

and what part of the code must go in a file? I've put this part in a file
Code:
-F\" 'FNR==NR && FNR>1 {gsub(",","",$5); N[$2]=$5;next}
$10 in N && FNR>1 {
Y[$10]=$8
Z[$10]=(N[$10]==$8)?"Yes:"No";
}
END{
for(k in N) {print k,Y[k],N[k],Z[k]?Z[k]:"Not_Found"}
}' file2 file1

and doesn't work.

If I put the -F\" outside of the file and I do this:
Code:
awk -f -F\" script.sh

fails too.

I don't know how should be the correct way to put it within a file. Please help me.

Thanks again
# 11  
Old 10-16-2012
awk -F\" -f op.awk file2 file1
op.awk:
Code:
FNR==NR && FNR>1 {
    gsub(",","",$5)
    N[$2]=$5;next
} 
$10 in N && FNR>1 {
    Y[$10]=$8
    Z[$10]=(N[$10]==$8)?"Yes":"No"
} 

END { 
   for(k in N) 
      print k,Y[k],N[k],Z[k]?Z[k]:"Not_Found"
}

# 12  
Old 10-16-2012
hello vgersh9,

The result using:
Code:
awk -F\" -f op.awk file2 file1

is the same as running the awk script in the other way
Code:
. script file2 file1

Only prints correctly the first 2 lines. For the rest of lines, is not printing column1 nor column2,
it seems a problem with the arrays, like the arrays don't have or don't store any value.

But again, the script works in Cygwin just perfect.

Thanks for any help.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Problem running db2 commands in awk

Hi , I am trying to use the below in awk but failed, any one assist please, awk '{ print $0; if ( $0 ~ /LOADTMP1/ ) { print $4; Table_name=system($( db2 -x "SELECT TRIM(TD.BSCHEMA) || '.' || TRIM(TD.BNAME) AS TABLE_NAME FROM SYSCAT.TABDEP TD WHERE TD.BTYPE='T' AND... (2 Replies)
Discussion started by: Nandy
2 Replies

2. Solaris

Script problem when running on crontab

Hi guys! I created a backup script that works fine when I run manually, but when I put a crontab job to execute it the result are not the expected. (not a time problem). Here is my script: bash-3.00# cat /bk_tool/backup2.sh #!/usr/bin/csh clear set DIR_HOST='SCP08' ... (3 Replies)
Discussion started by: andredemartini
3 Replies

3. Shell Programming and Scripting

Problem on running a script

Hi all, Running follow command on terminal; $ glance -T cloudlive -I ubuntu -K ubuntu123 -N \ http://127.0.0.1:5000/v2.0/OpenX add name="cirros" is_public=true \ container_format=ovf disk_format=raw < \ /srv/cirros-0.3.0-x86_64-disk.img It works without problem. Putting it on a... (5 Replies)
Discussion started by: satimis
5 Replies

4. Emergency UNIX and Linux Support

Problem with running Ghost Script

I have getting problem with running gs on a non global zone. This is new zone. Seems something to do with library, but I am not getting correct pointer. -bash-3.00$ which gs /usr/local/bin/gs -bash-3.00$ gs ld.so.1: gs: fatal: libcairo.so.2: open failed: No such file or directory Killed... (3 Replies)
Discussion started by: solaris_1977
3 Replies

5. Shell Programming and Scripting

Problem with running awk script in pbs file

Hi guys I have a problem with one module of my script. It's awk script running in pbs file - It's working when I make a call from pbs to separate awk only file like this but when I try to execute this code in pbs file it fails awk 'BEGIN { max = -1000; min = 1000 } { {$4 == "TCO"} ... (2 Replies)
Discussion started by: grincz
2 Replies

6. Shell Programming and Scripting

Problem running a program/script in the background from a script

Hi all, I have a script that calls another program/script, xxx, to run in the background. Supposedly this program at most should finish within five (5) minutes so after five (5) minutes, I run some other steps to run the script into completion. My problem is sometimes the program takes... (5 Replies)
Discussion started by: newbie_01
5 Replies

7. Shell Programming and Scripting

Problem in running a shell script

Hi, I'm trying to run a simple shell script whose contents are pasted below. #!/usr/bin/ksh echo $PATH performbuild { echo "Inside performBuild function" } echo "Main Shell started" performbuild echo "Main Shell ended" DV> ls -ltr total 48 -rwxr-xr-x 1 pb5377 it-ibm ... (5 Replies)
Discussion started by: blp_18
5 Replies

8. UNIX for Dummies Questions & Answers

problem running script

hey, i'm trying to run several processes due 2 loops : the code is: cd ${TIBCO_HOME}/tra/domain/${DOMAIN}/application/ for app_name in ls * do echo $app_name if && && ; then exit else echo $app_name cd $app_name pwd for ps_name in ls *.sh do echo... (2 Replies)
Discussion started by: ohadr
2 Replies

9. UNIX for Advanced & Expert Users

Problem in running an AWK script

Hi Everyone, I am required to write an AWK script that can be run from any directory. This script finds subscription rates for each subscriber at an interval of 10 mins. I want that just by copy pasting the whole script in shell prompt and giving the input arguments, script must work. Currenty... (4 Replies)
Discussion started by: rachana8p
4 Replies

10. Shell Programming and Scripting

Problem in Running Script

Hi friends, i have written one small script named as "size.sh"..... while running its giving syntax error at line no 2: 'str=$' unexpected. How to run this file ??? please help me. file content is : ----------------------------- #!/bin/sh str=$( df -k | grep /usr/local)... (14 Replies)
Discussion started by: samfrance
14 Replies
Login or Register to Ask a Question