Sponsored Content
Top Forums UNIX for Dummies Questions & Answers [SOLVED] Field $() is incorrect 'what does it mean' Post 302703835 by Bruble on Thursday 20th of September 2012 12:09:43 PM
Old 09-20-2012
[SOLVED] Field $() is incorrect 'what does it mean'

I am creating (or trying to) an awk script to retrieve various data from an input file and output the data in a different format. I think it is self explanatory what I am attempting but I getting the error Field $() isincorrect when I reun it using
Code:
awk -f file.awk inputfile

Code:
 
#!/bin/awk -f
#get text between 'starting' and 'Ending'
#
BEGIN {
OFS=","
}
#'start loop here'
  /Starting/,/Ending/ {
#if the line contains 'starting'
    if ($0 ~ /starting/) {
       day=substr($0,8,3);
       month=substr($0,12,3);
       date=substr($0,16,2);
       sthour=substr($0,19,2);
       stmin=substr($0,22,2);
       stsec=substr($0,25/2);
       year=substr($0,28,4);
       number=substr($0,33,5);
    }
#if the line contains 'LN'
    if ($0 ~ /LN/) {
       depot=substr($0,58,3);
       order=substr($0,61,5);
    }
#if the line contains 'Ending'
    if ($0 ~ /Ending/) {
       endhour=substr($0,19,2);
       endmin=substr($0,22,2);
       endsec=substr($0,25/2);
    }
 }
#'leave loop here'
durhour=$endhour-$sthour;
durmin=$endmin-$stmin;
dursec=$endsec-$stsec;
END {
  print $year $month $date $sthour $stmin $stsec $endhour $endmin $endsec $durhour $durmin $dursec 
$depot $order
  }

I hope someone can explain why this may be the case.

Thanks in advance.
 

10 More Discussions You Might Find Interesting

1. Forum Support Area for Unregistered Users & Account Problems

user name is incorrect

Hello. I registered yesterday with a username of "kailor" and a password of removed. I could only logon with a username of "keithailor@comc" and the above password. I want my username to become "kailor" and my password to remain as removed. Please email me with the steps to correct this. ... (1 Reply)
Discussion started by: keithailor@comc
1 Replies

2. UNIX for Dummies Questions & Answers

login incorrect

Hi to all, I get a problem when i tried to modifie the password of the root,but thi s the message i have on root password,even i put the old password i have the same message "password has expired, you are allowed to entry by daemon"Could any one give me any suggestion to solve the problem?... (2 Replies)
Discussion started by: espace1000
2 Replies

3. Shell Programming and Scripting

[solved] merging two files and writing to another file- solved

i have two files as file1: 1 2 3 file2: a b c and the output should be: file3: 1~a 2~b 3~c (1 Reply)
Discussion started by: mlpathir
1 Replies

4. Solaris

[Solved] Solaris 10 - Ftp Login incorrect

Hey everyone, I am trying to get a 2GB patch cluster FTP'd to a solaris 10 server. I have tried logging in via ftp, and both with root as well as my personal account, I get "Login Incorrect." I have verified that I can log in using telnet. -bash-3.00$ netstat -a |grep ftp *.ftp ... (10 Replies)
Discussion started by: msarro
10 Replies

5. Shell Programming and Scripting

[Solved] Need help changing a field from MM/DD/YY to DD/MM/YY format

Hi, I need help changing a field from MM/DD/YY to DD/MM/YY format. Suppose a file a.csv. The record is "11/16/09","ABC"," 1","EU","520892414","1","600","31351000","1234567","ANR BANK CO. LTD" "11/16/09","PQR"," 2","EU","520892427","1","600","31351000","5467897","ANR BANK CO.... (4 Replies)
Discussion started by: Gangadhar Reddy
4 Replies

6. Shell Programming and Scripting

[Solved] sort on numeric part of field

I have ran into a heavy case of PEBCAK*) and could need some advice on what i do wrong: OS is Linux (kernel 2.6.35), sort --version reports "8.5" from 2010, shell is ksh. Originally i had a file with with the following structure: hdisk1 yyy hdisk2 yyy hdisk3 yyy hdisk4 yyy hdisk5 yyy... (2 Replies)
Discussion started by: bakunin
2 Replies

7. Shell Programming and Scripting

[Solved] Counting specific characters within each field

Hello, I have a file like following: ALB_13554 1 1 1 ALB_13554 1 2 1 ALB_18544 2 0 2 ALB_18544 1 0 1 This is a sample of my file, my real file has 441845 number of fields. What I want to do is to calculate the number of 1 and 2 in each column using AWK, so, the output file looks like... (5 Replies)
Discussion started by: Homa
5 Replies

8. Shell Programming and Scripting

[SOLVED] How to set field separator in awk when FS is "||" ?

Dear Experts, How to use field separator in awk , when the field separation is needed as "||" Example: (file1 ) aa || bb || cc || 1234 xx || yy || zz || 1123 Q: If I want to print $3 and $4 only , with using the field separator "||" How to write awk code: (6 Replies)
Discussion started by: rveri
6 Replies

9. UNIX for Dummies Questions & Answers

ID incorrect field values in dat file and output to new file

Hi All I have a .dat file, the values are seperated by ". I wish to identify all field values in field 14 that are not '01-APR-2013' band then copy those records to a new file. Can anyone suggest the UNIX command required. Thanks in advance Andy (2 Replies)
Discussion started by: aurum1313
2 Replies

10. UNIX for Dummies Questions & Answers

[Solved] Awk: count occurrence of each character for every field

Hi, let's say an input looks like: A|C|C|D A|C|I|E A|B|I|C A|T|I|B as the title of the thread explains, I am trying to get something like: 1|A=4 2|C=2|B=1|T=1 3|I=3|C=1 4|D=1|E=1|C=1|B=1 i.e. a count of every character in each field (first column of output) independently, sorted... (4 Replies)
Discussion started by: beca123456
4 Replies
mailq(1)							   User Commands							  mailq(1)

NAME
mailq - print the mail queue SYNOPSIS
/usr/bin/mailq [-Ac] [-q subarg] [-v] DESCRIPTION
The mailq utility displays a summary of the mail messages queued for future delivery. The first line displayed for each mail message shows the internal identifier used on this host for the message, the size of the message in bytes, the date and time the message was accepted into the queue, and the envelope sender of the message. The second line of the display shows the error message that caused this message to be retained in the queue. This line will not be displayed if the message is being pro- cessed for the first time. The mailq utility used to be identical to sendmail -bp. Now it checks for the authorization attribute, solaris.mail.mailq. If the check for the invoking user succeeds, sendmail -bp is executed with the remaining argument vector. Otherwise, an error message is printed. This authorization attribute is by default enabled for all users. It can be disabled by modifying the Basic Solaris User entry in prof_attr(4). OPTIONS
The following options are supported: -Ac Like sendmail(1M), this flag tells mailq to use submit.cf rather than sendmail.cf even if the operation mode does not indicate an initial mail submission. This will result in the client queue /var/spool/clientmqueue being displayed rather than the default server queue /var/spool/mqueue. -qp[time] Similar to -qtime, except that instead of periodically forking a child to process the queue, sendmail forks a single per- sistent child for each queue that alternates between processing the queue and sleeping. The sleep time is given as the argument. The sleep time default is 1 second. The process will always sleep at least 5 seconds if the queue was empty in the previous queue run. -qf Processes saved messages in the queue once and does not fork(), but runs in the foreground. -qG name Processes jobs in the queue group called name only. -q[!]I substr Limits processed jobs to those containing substr as a substring of the queue id, or not when ! is specified. -q[!]R substr Limits processed jobs to those containing substr as a substring of one of the recipients, or not when ! is specified. -q[!]S substr Limits processed jobs to those containing substr as a substring of the sender, or not when ! is specified. -v Prints verbose information. This adds the priority of the message and a single character indicator (+ or blank) indicating whether a warning message has been sent on the first line of the message. Additionally, extra lines may be intermixed with the recipients that indicate the "controlling user" information. This shows who will own any programs that are executed on behalf of this message and the name of the alias this command is expanded from, if any. EXIT STATUS
0 Successful completion. >0 An error occurred. FILES
/etc/security/prof_attr local source for execution profile attributes /var/spool/mqueue default server queue /var/spool/clientmqueue client queue ATTRIBUTES
See attributes(5) for descriptions of the following attributes: +-----------------------------+-----------------------------+ | ATTRIBUTE TYPE | ATTRIBUTE VALUE | +-----------------------------+-----------------------------+ |Availability |SUNWsndmu | +-----------------------------+-----------------------------+ SEE ALSO
sendmail(1M), prof_attr(4), attributes(5) SunOS 5.10 10 Jul 2002 mailq(1)
All times are GMT -4. The time now is 12:10 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy