error in awk command


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting error in awk command
# 1  
Old 05-06-2009
error in awk command

ls filename*.txt | awk -F".Y" '$2 < $v_RUN_DT && $2 > $v_LOAD_DT'|awk ' NR==1'
I am getting this error . Can somebody plz point me where is the problem.
awk: 0602-562 Field $() is not correct.
The input line number is 1.
The source line number is 1.
# 2  
Old 05-06-2009
Code:
awk -F".Y" '$2 < vr && $2 > vl' vr="{v_RUN_DT}" vl="${v_LOAD_DT}" filename*.txt

# 3  
Old 05-07-2009
Vgersh is there some problem in the code

awk -F".Y" '$2 < vr && $2 > vl' vr="{v_RUN_DT}" vl="${v_LOAD_DT}" filename*.txt

did u miss a $ in front of the v_run_dt
# 4  
Old 05-07-2009
Quote:
Originally Posted by RubinPat
Vgersh is there some problem in the code

awk -F".Y" '$2 < vr && $2 > vl' vr="{v_RUN_DT}" vl="${v_LOAD_DT}" filename*.txt

did u miss a $ in front of the v_run_dt
yes, I did - fat fingers!
Code:
awk -F".Y" '$2 < vr && $2 > vl' vr="${v_RUN_DT}" vl="${v_LOAD_DT}" filename*.txt

# 5  
Old 05-07-2009
Hi Vgersh,

awk -F".Y" '$2 < vr && $2 > vl' vr="${v_RUN_DT}" vl="${v_LOAD_DT}" filename*.txt

The above command works fine but I now realised that its not giving the criteria
For ex:

awk -F".Y" '$2 < vr && $2 > vl' vr="20090502" vl="20090429" filename*.txt

I need the

filename.20090502.txt
filename.20090501.txt
filename.20090430.txt

But I am getting

filename.20090501.txt
filename.20090430.txt
filename.20090429.txt

I tried less than , greater than it doesn't give .. Can u plz point it out plz?

Thanks,
# 6  
Old 05-07-2009
try this:
Code:
awk -F".Y" 'int($2) < int(vr) && int($2) > int(vl)' vr="${v_RUN_DT}" vl="${v_LOAD_DT}" filename*.txt

# 7  
Old 05-07-2009
This is not working Vgersh

I am getting more files now
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Solaris

awk command error in Solaris

I have the following code that works perfectly in Cygwin $ awk -F, ' BEGIN {months ="AP01"; months ="AP02"; months ="AP03"; months ="AP04"; months ="AP05"; months ="AP06"; months ="AP07"; months ="AP08"; months ="AP09"; months ="AP10"; months ="AP11"; months... (3 Replies)
Discussion started by: Raul_Rodriguez
3 Replies

2. Shell Programming and Scripting

Spot error with my awk command

can any one identify why this command keeps resulting in 1, even though the string i'm searching for actually does not exist in the log? awk 'BEGIN{count++} NR>220 && NR<=223 && /error/ && !/No.*such.*file.*or.*direfctory/ { count++ } END { print count }' /var/log/mail.log i expected it to... (2 Replies)
Discussion started by: SkySmart
2 Replies

3. Shell Programming and Scripting

Bash script with awk command ERROR

Hello im new here... Im trying to read file and create folders from words in it but i get this for loop error awk : line 3 : syntax error at or near for my code is.. #!/bin/bash begin for (( i=1;i<=5;i++)); do awk -v i=$i $0 { print $i } mkdir $i done {print $i} end {} i have... (7 Replies)
Discussion started by: boxstep
7 Replies

4. Shell Programming and Scripting

Pass awk field to a command line executed within awk

Hi, I am trying to pass awk field to a command line executed within awk (need to convert a timestamp into formatted date). All my attempts failed this far. Here's an example. It works fine with timestamp hard-codded into the command echo "1381653229 something" |awk 'BEGIN{cmd="date -d... (4 Replies)
Discussion started by: tuxer
4 Replies

5. Shell Programming and Scripting

sed and awk giving error ./sample.sh: line 13: sed: command not found

Hi, I am running a script sample.sh in bash environment .In the script i am using sed and awk commands which when executed individually from terminal they are getting executed normally but when i give these sed and awk commands in the script it is giving the below errors :- ./sample.sh: line... (12 Replies)
Discussion started by: satishmallidi
12 Replies

6. Shell Programming and Scripting

Getting syntax error while running awk command

Hello Gurus, I am firing the below command : df -g | grep -v var| awk '{ (if $4 > 90% ) print "Filesystem", $NF,"over sized";}' But I am getting the below error:- ====== syntax error The source line is 1. The error context is {if ($4 > >>> 90%) <<< awk: The... (9 Replies)
Discussion started by: pokhraj_d
9 Replies

7. 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

8. Shell Programming and Scripting

awk command to compare a file with set of files in a directory using 'awk'

Hi, I have a situation to compare one file, say file1.txt with a set of files in directory.The directory contains more than 100 files. To be more precise, the requirement is to compare the first field of file1.txt with the first field in all the files in the directory.The files in the... (10 Replies)
Discussion started by: anandek
10 Replies

9. Shell Programming and Scripting

Error passing parameter in "sub" command in awk

I have to replace the pattern found in one file in another file with null/empty "" if found on the fields 3 or 4 ONLY File 1 ==== 10604747|Mxdef|9999|9999|9999|2012-03-04 00:00:59 10604747|Mcdef|8888|9999|8888|2012-03-04 00:00:59 . . . File 2 ==== 9999 8888 . . . Expected... (7 Replies)
Discussion started by: machomaddy
7 Replies

10. Shell Programming and Scripting

awk command in script gives error while same awk command at prompt runs fine: Why?

Hello all, Here is what my bash script does: sums number columns, saves the tot in new column, outputs if tot >= threshold val: > cat getnon0file.sh #!/bin/bash this="getnon0file.sh" USAGE=$this" InFile="xyz.38" Min="0.05" # awk '{sum=0; for(n=2; n<=NF; n++){sum+=$n};... (4 Replies)
Discussion started by: catalys
4 Replies
Login or Register to Ask a Question