Computing.Net > Forums > Unix > Awk not working

Computing.Net: Over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to sign up now, it's free!

Awk not working

Reply to Message Icon

Original Message
Name: ahmedwaseem2000
Date: August 19, 2005 at 08:08:40 Pacific
Subject: Awk not working
OS: UNIX
CPU/Ram: lsf
Comment:

Hi Can any one help me with this code. This is created by someone else and i am trying to modify it so i have got very less knowledge about the purpose.

Ok, the code was picking the second last field of a file with the below mentioned awk. Now when i try to pick 7th to last field (by replacing 1 with 7) it gives me the error awk: The field -6 must be in the range 0 to 199.

Please HELP!!!!!

awk -F${SEP} -v tmpfic=${TMPFIC} ' BEGIN { master =0 }
{
if (NR==1 && index("QuoteMast",FILENAME)) master=1;


if (/QUOT_MAIN_ID.*,.*QUOT_MAIN_REVI/ || /Funding,TeamPlay ID,Project Name,MSDD Project/) {
getline;
}
if ($1 ~ /^[a-zA-Z]{3}.?[a-zA-Z]{4}[0-9]?[0-9]{3} *$/)
{
if (NR==2) printf("%s",$0) >> tmpfic; else printf("\n%s",$0) >> tmpfic;
testok = $(NF-1);
}
else {
debut = 0;
printf("%s", $0) >> tmpfic;
testok = $(NF-1);
while(!debut && getline)
{
if ($1 ~ /^[a-zA-Z]{3}.?[a-zA-Z]{4}[0-9]?[0-9]{3} *$/)
{
if ((master && testok=="false") || !master ) {
printf("\n%s",$0) >> tmpfic;
debut=1;
} else { printf("%s", $0) >> tmpfic; }
}
else {
printf("%s", $0) >> tmpfic;
}
testok = $(NF-1);
};
}
}' ${FIC}.$$



Report Offensive Message For Removal








Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Unix Forum Home



Results for: Awk not working

substring function does not work
    Summary: The bash syntax ${alpha:5:5} will not work on HP-UX.  Following are 4 solutions that will provide the fghij result when $alpha is 10 characters or longer.  But when $alpha is less than 10 characters...
www.computing.net/answers/unix/substring-function-does-not-work/6664.html

Encryption Code Not Working
    Summary: Can someone please help me to understand why the following code is not working? Once compiled, it displays the usage error message. I can't figure why... #include <stdio.h> #define PROG_NAME "xe" v...
www.computing.net/answers/unix/encryption-code-not-working/5974.html

File Redirection Is Not Working
    Summary: The below commands writes the line to the screen if it finds the "error" string in the logfile.txt tail -f logfile.txt | grep error However if I try to redirect the output of the grep to a file like s...
www.computing.net/answers/unix/file-redirection-is-not-working/8096.html








Which MP3 player do you have?

iPod/iPhone
Zune
Something Else
None


View Results

Poll Finishes In 2 Days.
Discuss in The Lounge
Poll History






Data Recovery Software