Sponsored Content
Full Discussion: awk doubt
Top Forums UNIX for Dummies Questions & Answers awk doubt Post 7824 by vadivel on Tuesday 2nd of October 2001 01:39:41 PM
Old 10-02-2001
Sort is not reliable for all fields.

Hi,

thanks for ur response. But that sort option is
not working. My file is like,

ABCD 2.03 0.00 123.00 0.00
ACB 0.00 25.00 0.00 123.23
ABVCERR[12] 0.00 456.00 98.00 0.00

like this I want to sort with the last field.
As every field is of various length and 5 spaces
between fields, I'm not able to use sort command
like sort -t\ +3rn < file
it is giving some garbage results. That's why
I want an awk program which will be a secured one.
Thanks for any input.

Regards,
vadivel.
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

doubt in AWK

Hi all, column1 -------- 33 44 55 66 please provide the script using awk command to dispaly output 55. Help apperciated.. thanks, Nirmal (4 Replies)
Discussion started by: abnirmal
4 Replies

2. Shell Programming and Scripting

awk doubt

hi how to get the values in two columns (may be 2nd and 5th column) of a file line by line. either i want to get the two fields into different variables and use a for loop to get these values line by line. (3 Replies)
Discussion started by: Pradee
3 Replies

3. UNIX for Dummies Questions & Answers

doubt about awk

i have a file like this: awk.lst smith : sales : 1200 : 2 jones:it:25000 : 2 roger : it : 1500 : 2 ravi | acct | 15000 i have 3 doubts 1) when i say awk -F ":" '$2 ~ /'it'/ {print $0}' awk.lst i am not able to get jones in the ouput , is it because of space issue? 2)how to... (2 Replies)
Discussion started by: soujanya_srk
2 Replies

4. Shell Programming and Scripting

AWK doubt

Hello people I have a doubt about awk... I´m using it to create a condition where I do not want to use the 0 (zero) value of a certain column. - This is the original file: string,number,date abc,0,20050101 def,1,20060101 ghi,2,20040101 jkl,12,20090101 mno,123,20020101... (2 Replies)
Discussion started by: Rafael.Buria
2 Replies

5. Shell Programming and Scripting

doubt in awk

Hi , I have a file in the below format: 1.txt awk 'BEGIN { printf ("%1s", "man" )} ' awk 'BEGIN { printf ("%9s", "women" )} ' awk 'BEGIN { printf ("%56s", "human")} ' ## ### ## echo "$!" ## awk 'BEGIN { printf ("%1s", "aaa" )} ' awk 'BEGIN { printf ("%19s", "bbb" )} ' ... (4 Replies)
Discussion started by: jisha
4 Replies

6. Shell Programming and Scripting

doubt on awk

I have executed the below command: find . -name "Ks*" -type f -exec ls -ltr {} \; | awk '{printf("%ld %s %d %s \n",$5,$6,$7,$8,$9)}' and here is the output: 1282 Oct 7 2004 51590 Jul 10 2006 921 Oct 7 2004 1389 Jun 4 2003 1037 May 19 2004 334 Mar 24 2004 672 Jul 8 2003 977... (6 Replies)
Discussion started by: venkatesht
6 Replies

7. Shell Programming and Scripting

Awk doubt

I have a file sample.txt with the following contents: the following gives output as awk 'NF{s=$0; print s}' sample.txt but, awk 'NF{s=$0}{print s}' sample.txtgives output as why this difference, can someone explain me? (6 Replies)
Discussion started by: royalibrahim
6 Replies

8. UNIX for Dummies Questions & Answers

a doubt in awk

instead of writing print command in awk, i saw in some posts that we can simply write a number before we end the awk command and it will print the file. As given below: $awk '{some manipulation; print}' filename $awk '{some manipulation}1' filename I also tried replacing the... (2 Replies)
Discussion started by: PranavEcstasy
2 Replies

9. Shell Programming and Scripting

Doubt on using AWK

DE_CODE|1{AXXANY}1APP_NAME|2{TELCO}2LOC|NY DE_CODE|1{AXXATX}1APP_NAME|2{TELCO}2LOC|TX DE_CODE|1{AXXABT}1APP_NAME|2{TELCO}2LOC|BT DE_CODE|1{AXXANJ}1APP_NAME|2{TELCO}2LOC|NJ i have out put file like below i have to convert it in the format as below. DE_CODE = AXXANY APP_NAME= TELCO LOC = NY... (4 Replies)
Discussion started by: mail2sant
4 Replies

10. Shell Programming and Scripting

Doubt in awk

Hi, I got a below requirement from this forum, but the solution provided was not clear. Below is the requirement Input file A 1 Z A 1 ZZ B 2 Y B 2 AA Required output B Y|AA A Z|ZZ (5 Replies)
Discussion started by: stew
5 Replies
join(1) 							   User Commands							   join(1)

NAME
join - relational database operator SYNOPSIS
join [-a filenumber | -v filenumber] [-1 fieldnumber] [-2 fieldnumber] [-o list] [-e string] [-t char] file1 file2 join [-a filenumber] [-j fieldnumber] [-j1 fieldnumber] [-j2 fieldnumber] [-o list] [-e string] [-t char] file1 file2 DESCRIPTION
The join command forms, on the standard output, a join of the two relations specified by the lines of file1 and file2. There is one line in the output for each pair of lines in file1 and file2 that have identical join fields. The output line normally con- sists of the common field, then the rest of the line from file1, then the rest of the line from file2. This format can be changed by using the -o option (see below). The -a option can be used to add unmatched lines to the output. The -v option can be used to output only unmatched lines. The default input field separators are blank, tab, or new-line. In this case, multiple separators count as one field separator, and leading separators are ignored. The default output field separator is a blank. If the input files are not in the appropriate collating sequence, the results are unspecified. OPTIONS
Some of the options below use the argument filenumber. This argument should be a 1 or a 2 referring to either file1 or file2, respectively. -a filenumber In addition to the normal output, produce a line for each unpairable line in file filenumber, where filenumber is 1 or 2. If both -a 1 and -a 2 are specified, all unpairable lines will be output. -e string Replace empty output fields in the list selected by option -o with the string string. -j fieldnumber Equivalent to -1fieldnumber -2fieldnumber. -j1 fieldnumber Equivalent to -1fieldnumber. -j2 fieldnumber Equivalent to -2fieldnumber. Fields are numbered starting with 1. -o list Each output line includes the fields specified in list. Fields selected by list that do not appear in the input will be treated as empty output fields. (See the -e option.) Each element of which has the either the form filenum- ber.fieldnumber, or 0, which represents the join field. The common field is not printed unless specifically requested. -t char Use character char as a separator. Every appearance of char in a line is significant. The character char is used as the field separator for both input and output. With this option specified, the collating term should be the same as sort without the -b option. -v filenumber Instead of the default output, produce a line only for each unpairable line in filenumber, where filenumber is 1 or 2. If both -v 1 and -v 2 are specified, all unpairable lines will be output. -1 fieldnumber Join on the fieldnumberth field of file 1. Fields are decimal integers starting with 1. -2fieldnumber Join on the fieldnumberth field of file 2. Fields are decimal integers starting with 1. OPERANDS
The following operands are supported: file1 file2 A path name of a file to be joined. If either of the file1 or file2 operands is -, the standard input is used in its place. file1 and file2 must be sorted in increasing collating sequence as determined by LC_COLLATE on the fields on which they are to be joined, normally the first in each line (see sort(1)). USAGE
See largefile(5) for the description of the behavior of join when encountering files greater than or equal to 2 Gbyte (2**31 bytes). EXAMPLES
Example 1: Joining the password file and group file The following command line will join the password file and the group file, matching on the numeric group ID, and outputting the login name, the group name and the login directory. It is assumed that the files have been sorted in ASCII collating sequence on the group ID fields. example% join -j1 4-j2 3 -o 1.1 2.1 1.6 -t:/etc/passwd /etc/group Example 2: Using the -o option The -o 0 field essentially selects the union of the join fields. For example, given file phone: !Name Phone Number Don +1 123-456-7890 Hal +1 234-567-8901 Yasushi +2 345-678-9012 and file fax: !Name Fax Number Don +1 123-456-7899 Keith +1 456-789-0122 Yasushi +2 345-678-9011 where the large expanses of white space are meant to each represent a single tab character), the command: example% join -t"tab" -a 1 -a 2 -e '(unknown)' -o 0,1.2,2.2 phone fax would produce !Name Phone Number Fax Number Don +1 123-456-7890 +1 123-456-7899 Hal +1 234-567-8901 (unknown Keith (unknown) +1 456-789-012 Yasushi +2 345-678-9012 +2 345-678-9011 ENVIRONMENT VARIABLES
See environ(5) for descriptions of the following environment variables that affect the execution of join: LANG, LC_ALL, LC_CTYPE, LC_MES- SAGES, LC_COLLATE, and NLSPATH. EXIT STATUS
The following exit values are returned: 0 All input files were output successfully. >0 An error occurred. ATTRIBUTES
See attributes(5) for descriptions of the following attributes: +-----------------------------+-----------------------------+ | ATTRIBUTE TYPE | ATTRIBUTE VALUE | +-----------------------------+-----------------------------+ |Availability |SUNWcsu | +-----------------------------+-----------------------------+ |CSI |Enabled | +-----------------------------+-----------------------------+ |Interface Stability |Standard | +-----------------------------+-----------------------------+ SEE ALSO
awk(1), comm(1), sort(1), uniq(1), attributes(5), environ(5), largefile(5), standards(5) NOTES
With default field separation, the collating sequence is that of sort -b; with -t, the sequence is that of a plain sort. The conventions of the join, sort, comm, uniq, and awk commands are wildly incongruous. SunOS 5.10 8 Feb 2000 join(1)
All times are GMT -4. The time now is 09:09 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy