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 wanted to cut the feilds comming after % and After $ at one go
can we do some thing like this cut -f 2 -d "%|$" (But it doesnot work)
Input File
BWPG %TCPRP1 $SCSPR000
BWPH %TCPRP1 $SCSPR003
BWPI %TRTYUP ResourceDescription="IMPRIMANTE " $BWOPTY
BWPJ %ZOMBIE ... (4 Replies)
Hi,
I have a requirement whereby I have to sort a flat file based on Multiple Columns (similar to ORDER BY Clause of Oracle). I am getting 10 columns in the flat file and I want the file to be sorted on 1st, 3rd, 4th, 7th and 9th columns in ascending order. The flat file is pipe seperated.
Any... (15 Replies)
Hi All,
I am encountered with a problem while sorting a file based on multiple columns . I need to sort like:
(field2,ascending) , (field3,ascending) ,(field8,descending) , (field7,ascending),(field13,ascending).
So far i was sorting only in ascending order but here i need to use one... (1 Reply)
I have the following string sample:
bla bla bla bla bla
I would like to extract the "123" using awk.
I thought about awk -F"]" '{ print $1 }' but it doesn't work
Any ideas ? (7 Replies)
Hello
If you wanted to sort a .csv file that was filled with lines like this:
<Ticker>,<Date as YYYYMMDD>,<Time as H:M:S>,<Volume>,<Corr>
(H : , M, S: )
by date, does anybody know of a better solution than to turn the 3rd and 4th colons of every line into commas, sorting on four keys,... (20 Replies)
Hi,
I have a problem to concatenate the lines based on number of delimiters (if the delimiter count is 9 then concatenate all the fields & remove the new line char bw delimiters and then write the following data into second line) in a file.
my input file content is
Title| ID| Owner|... (4 Replies)
Hi, I need to display the last column value in the below o/p.
sam2 PS 03/10/11 0 441
Unable to get o/p with this awk code
awk -F"+" '{ print $4 }' pwdchk.txt
I need to display 441(in this eg.) and also accept it as a variable to treat it with if condition and take a decision.... (1 Reply)
Hi Folks,
This is the first time I ever encountered this situation
My input file is of this kind
cat input.txt
1 PAIXAF 0 1 1 -9 0 0 0 1 2 0 2 1 2 1
7 PAIXEM 0 7 1 -9 1 0 2 0 1 2 2 1 0 2
9 PAKZXY 0 2 1 -9 2 0 1 1 1 0 1 2 0 1
Till the sixth column (which is -9), I want my columns to... (4 Replies)
Hi,
I have a requirement where in I need to insert delimiters before the last column of the total delimiters is less than a specified number.
Say if the delimiters is less than 139, I need to insert 2 columns ( with blanks) before the last field
awk -F 'Ç' '{ if (NF-1 < 139)} END { "Insert 2... (5 Replies)
Discussion started by: arunkesi
5 Replies
LEARN ABOUT PLAN9
getfields
GETFIELDS(2) System Calls Manual GETFIELDS(2)NAME
getfields, getmfields, setfields, tokenize - break a string into fields
SYNOPSIS
#include <u.h>
#include <libc.h>
int getfields(char *str, char **ptrs, int nptrs)
int getmfields(char *str, char **ptrs, int nptrs)
char* setfields(char *fielddelim)
int tokenize(char *str, char **args, int max)
DESCRIPTION
Getfields breaks the null-terminated string str into at most nptrs null-terminated fields and places pointers to the start of these fields
in the array ptrs. It returns the number of fields and terminates the list of pointers with a zero pointer. It overwrites some of the
bytes in str. If there are nptr or more fields, the list will not end with zero and the last `field' will extend to the end of the input
string and may contain delimiters.
A field is defined as a maximal sequence of characters not in a set of field delimiters. Adjacent fields are separated by exactly one
delimiter. No field follows a delimiter at the end of string. Thus a string of just two delimiter characters contains two empty fields,
and a nonempty string with no delimiters contains one field.
Getmfields is the same as getfields except that fields are separated by maximal strings of field delimiters rather than just one.
Setfields makes the field delimiters (space and tab by default) be the characters of the string fielddelim and returns a pointer to a
string of the previous delimiters.
Tokenize breaks null-terminated string str into tokens by replacing every blank or newline with a null byte. Pointers to successive non-
empty tokens are placed in args. Processing stops after max tokens are processed. Tokenize returns the number of tokens processed. Tok-
enize does not terminate args with a null pointer.
Alef
Of these routines, only tokenize is in Alef.
SOURCE
/sys/src/libc/port/getfields.c
/sys/src/libc/port/tokenize.c
SEE ALSO
strtok in strcat(2)GETFIELDS(2)