Hi,
I have an urgent task here. I am required to sort a flat file based on multiple columns which are based on the character position in that line. I am restricted to use the character position instead of the space and sort +1 +2 etc to do the sorting.
I understand that there is a previous... (8 Replies)
Hi
I have the fixed width flat file having the following data
12345aaaaaaaaaabbbbbbbbbb
12365sssssssssscccccccccc
12365sssss
12367ddddddddddvvvvvvvvvv
12367 vvvvv
Here the first column is length 5 second is length 10 third is length 10
if the second or third column exceeds... (3 Replies)
Hi All,
I am a newbee in unix but still have written a shell script which should trigger a mail based on certain conditions but the problem is that my file is not being read. Below is the code please advise. I do not know where is it failing.
Note $ and the no followed with it is the no of... (1 Reply)
I have files with hundreds of sequences with missing characters represented by a dash ("-"), something like this
I need to go sequence by sequence and if a dash is found, it should be replaced with the most common character in that particular position. Thus, in my example the dash in the second... (6 Replies)
Hi
My file has a series of rows up to 160 characters in length.
There are 7 columns for each row.
In each row, column 1 starts at position 4
column 2 starts at position 12
column 3 starts at position 43
column 4 starts at position 82
column 5 starts at... (7 Replies)
Hello Guys
I want to sort a flat file by the third column (numeric ) and store it in some other name
I/P
9924873|20111114|00000000000013013|130|13|10/15/2010 12:36:22|W860944|N|00
9924873|20111114|00000000000013009|130|09|10/15/2010 12:36:22|W860944|N|00... (12 Replies)
Hi,
I have a flaty file from which i am fetching few columns in tablular form as below code.
Now i want to fetch the column 6 and 7 in below code only if it either of them is non zero.However below startement
awk -F, '$6==0 && $7==0{exit 1}' ${IFILE}
is not working..Not sure where is the... (36 Replies)
I have files with hundreds of sequences with frequency values reported as "Freq X" and missing characters represented by a dash ("-"), something like this
>39sample Freq 4
TAGATGTGCCCGTGGGTTTCCCGTCAACACCGGATAGTAGCAGCACTA
>22sample Freq 15
T-GATGTCGTGGGTTTCCCGTCAACACCGGCAAATAGTAGCAGCACTA... (12 Replies)
hi.
I have a Fixed Length text file as input where the character positions 4-5(two character positions starting from 4th position) indicates the LOB indicator. The file structure is something like below:
10126Apple DrinkOmaha
10231Milkshake New Jersey
103 Billabong Illinois
... (6 Replies)
Discussion started by: kumarjt
6 Replies
LEARN ABOUT ULTRIX
sort
sort(1) General Commands Manual sort(1)Name
sort - sort file data
Syntax
sort [options] [-k keydef] [+pos1[-pos2]] [file...]
Description
The command sorts lines of all the named files together and writes the result on the standard output. The name `-' means the standard
input. If no input files are named, the standard input is sorted.
Options
The default sort key is an entire line. Default ordering is lexicographic by bytes in machine collating sequence. The ordering is
affected globally by the following options, one or more of which may appear.
-b Ignores leading blanks (spaces and tabs) in field comparisons.
-d Sorts data according to dictionary ordering: letters, digits, and blanks only.
-f Folds uppercase to lowercase while sorting.
-i Ignore characters outside the ASCII range 040-0176 in nonnumeric comparisons.
-k keydef The keydefargument is a key field definition. The format is field_start, [field_end] [type], where field_start and field_end
are the definition of the restricted search key, and type is a modifier from the option list [bdfinr]. These modifiers have the
functionality, for this key only, that their command line counter-parts have for the entire record.
-n Sorts fields with numbers numerically. An initial numeric string, consisting of optional blanks, optional minus sign, and zero
or more digits with optional decimal point, is sorted by arithmetic value. (Note that -0 is taken to be equal to 0.) Option n
implies option b.
-r Reverses the sense of comparisons.
-tx Uses specified character as field separator.
The notation +pos1 -pos2 restricts a sort key to a field beginning at pos1 and ending just before pos2. Pos1 and pos2 each have the form
m.n, optionally followed by one or more of the options bdfinr, where m tells a number of fields to skip from the beginning of the line and
n tells a number of characters to skip further. If any options are present they override all the global ordering options for this key. If
the b option is in effect n is counted from the first nonblank in the field; b is attached independently to pos2. A missing .n means .0; a
missing -pos2 means the end of the line. Under the -tx option, fields are strings separated by x; otherwise fields are nonempty nonblank
strings separated by blanks.
When there are multiple sort keys, later keys are compared only after all earlier keys compare equal. Lines that otherwise compare equal
are ordered with all bytes significant.
These are additional options:
-c Checks sorting order and displays output only if out of order.
-m Merges previously sorted data.
-o name Uses specified file as output file. This file may be the same as one of the inputs.
-T dir Uses specified directory to build temporary files.
-u Suppresses all duplicate entries. Ignored bytes and bytes outside keys do not participate in this comparison.
Examples
Print in alphabetical order all the unique spellings in a list of words. Capitalized words differ from uncapitalized.
sort -u +0f +0 list
Print the password file, sorted by user id number (the 3rd colon-separated field).
sort -t: +2n /etc/passwd
Print the first instance of each month in an already sorted file of (month day) entries. The options -um with just one input file make the
choice of a unique representative from a set of equal lines predictable.
sort -um +0 -1 dates
Restrictions
Very long lines are silently truncated.
Diagnostics
Comments and exits with nonzero status for various trouble conditions and for disorder discovered under option c.
Files
/usr/tmp/stm*, /tmp/* first and second tries for temporary files
See Alsocomm(1), join(1), rev(1), uniq(1)sort(1)