Sponsored Content
Full Discussion: Extract Columns from file
Top Forums Shell Programming and Scripting Extract Columns from file Post 302343320 by mac4rfree on Wednesday 12th of August 2009 07:07:31 AM
Old 08-12-2009
Hi,
I hope this how u want the output:

Code:
awk -F, '{print "1st field : "$1 " 2nd field : " $2 " 3rd field : " $3}' test.dat



---------- Post updated at 04:37 PM ---------- Previous update was at 04:32 PM ----------

May be this will give you the desired output as shown by you.
Code:
awk -F, '{print "Input string : " $0 "\n" "1srt field : "$1 "\n" "2field : " $2 "\n" "3rd field : " $3 "\n"}' test.dat

Code:
d02 $ cat test.dat
This is,a testfile,for validation
This is ," a test file","for validation puropse"""
d02 $
d02 $ awk -F, '{print "Input string : " $0 "\n" "1srt field : "$1 "\n" "2field : " $2 "\n" "3rd field : " $3 "\n"}>
Input string : This is,a testfile,for validation
1srt field : This is
2field : a testfile
3rd field : for validation

Input string : This is ," a test file","for validation puropse"""
1srt field : This is
2field : " a test file"
3rd field : "for validation puropse"""

 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Extract text in 2 columns of output file.

Hello!! I have the text file with following format... --SubTotal-----------------------------------0--161---------------44---13739369-67--- --SubTotal-----------------------------------0--147---------------0----49643---1----... (2 Replies)
Discussion started by: Danish Shakil
2 Replies

2. Shell Programming and Scripting

how to extract columns from a text file

Hi, In ksh, I have a file with similar rows as follows: Department = 1234 G/L Asset Acct No = 12.0000. 2/29/2008 Department = 1234 G/L Asset Acct No = 13.0000. 3/29/2008. I want to create a new text file that contains only the numbers and date: 1234 12.0000. 2/29/2008 1234 13.0000. ... (16 Replies)
Discussion started by: ihot
16 Replies

3. Shell Programming and Scripting

Help, need to extract columns from file

I have huge fixed width, text file in unix box and I need to extract columns found between the width 105 and 200 and output it to a new file. Can anyone tell me how to extract it? Thanks for your help. (1 Reply)
Discussion started by: kiran2k
1 Replies

4. Shell Programming and Scripting

extract columns from 2 different files and create new file

Hi All, I have 2 issues while working with file. 1. I have 2 delimited(~) files. I want to extract column numbner 3 from file1 and column number 8 from file2 and paste it into file3. I have tried using cut, but not able to get answer. 2. i have 2 filxed-width file. I wanted to do same... (1 Reply)
Discussion started by: Amit.Sagpariya
1 Replies

5. Shell Programming and Scripting

fileutility to extract columns from source file

Hi experts,Please help me for the below requirement.i have a source file.(lets say contains 50 columns). I am extarcting five columns from the source file by using pattern file.for exampleinput file:--------a,b,c,d,"a,g","v b",s,koutputfile=======a,"a,g","v b",s,kThanks in advancesubhendu (1 Reply)
Discussion started by: subhendu81
1 Replies

6. Shell Programming and Scripting

extract columns from file and send mail

Hi I have a file of the form name1,lastname1,email1@gmail.com,9.08243E+12,team1,role1,username1,password1 name2,lastname2,email2@gmail.com,9.08243E+11,team2,role2,username2,password2 I need to extract the email (column 3) and send a mail to each person, with their details ( specifically... (3 Replies)
Discussion started by: pkabali
3 Replies

7. Shell Programming and Scripting

Command to extract all columns except the last few from a txt file

hello, i have publicly available txt file with little less than 300000 rows. i want to extract from column 1 to column 218 and save it in another text file. i use the cut command but the file is saved with multiple rows from the source file onto a single row in the destination. basically it is... (6 Replies)
Discussion started by: madrazzii
6 Replies

8. UNIX for Dummies Questions & Answers

Extract spread columns from large file

Dear all, I want to extract around 300 columns from a very large file with almost 2million columns. There are no headers, but I can find out which column numbers I want. I know I can extract with the function 'cut -f2' for example just the second column but how do I do this for such a large... (1 Reply)
Discussion started by: fndijk
1 Replies

9. Shell Programming and Scripting

Extract columns into seperate file

I have a comma delimited file as per the one below and I am currently extracting the values in 2 columns (COL1 & COL6) to produce a smaller trimmed down version of the file which only contains the columns we need; COL1,COL2,COL3,COL4,COL5,COL6,COL7,COL8,COL9... (1 Reply)
Discussion started by: Ads89
1 Replies

10. Shell Programming and Scripting

Match Columns in one file and extract columns from another file

Kindly help merging information from two files with the following data structure. I want to match for the CHR-SNP in Foo and get the columns that match from CHROM-rsID Fields 1 & 2 of foo may have duplicates, however, a joint key of Fields $1$2$3$4 is unique. Also would be helpful to clean up... (4 Replies)
Discussion started by: genehunter
4 Replies
form_fieldtype(3X)														form_fieldtype(3X)

NAME
form_fieldtype - define validation-field types SYNOPSIS
#include <form.h> FIELDTYPE *new_fieldtype( bool (* const field_check)(FIELD *, const void *), bool (* const char_check)(int, const void *)); int free_fieldtype(FIELDTYPE *fieldtype); int set_fieldtype_arg( FIELDTYPE *fieldtype, void *(* const make_arg)(va_list *), void *(* const copy_arg)(const void *), void (* const free_arg)(void *)); int set_fieldtype_choice( FIELDTYPE *fieldtype, bool (* const next_choice)(FIELD *, const void *), bool (* const prev_choice)(FIELD *, const void *)); FIELDTYPE *link_fieldtype(FIELDTYPE *type1, FIELDTYPE *type2); DESCRIPTION
The function new_fieldtype creates a new field type usable for data validation. You supply it with field_check, a predicate to check the validity of an entered data string whenever the user attempt to leave a field. The (FIELD *) argument is passed in so the validation pred- icate can see the field's buffer, sizes and other attributes; the second argument is an argument-block structure, about which more below. You also supply new_fieldtype with char_check, a function to validate input characters as they are entered; it will be passed the character to be checked and a pointer to an argument-block structure. The function free_fieldtype frees the space allocated for a given validation type. The function set_fieldtype_arg associates three storage-management functions with a field type. The make_arg function is automatically applied to the list of arguments you give set_field_type when attaching validation to a field; its job is to bundle these into an allocated argument-block object which can later be passed to validation predicated. The other two hook arguments should copy and free argument-block structures. They will be used by the forms-driver code. You must supply the make_arg function, the other two are optional, you may supply NULL for them. In this case it is assumed that make_arg does not allocate memory but simply loads the argument into a single scalar value. The form driver requests REQ_NEXT_CHOICE and REQ_PREV_CHOICE assume that the possible values of a field form an ordered set, and provide the forms user with a way to move through the set. The set_fieldtype_choice function allows forms programmers to define successor and pre- decessor functions for the field type. These functions take the field pointer and an argument-block structure as arguments. RETURN VALUE
The pointer-valued routines return NULL on error. The integer-valued routines return one of the following codes on error: E_OK The routine succeeded. E_SYSTEM_ERROR System error occurred (see errno). E_BAD_ARGUMENT Routine detected an incorrect or out-of-range argument. E_CONNECTED The field is already connected to a form. SEE ALSO
curses(3X), form(3X). NOTES
The header file <form.h> automatically includes the header file <curses.h>. All of the (char *) arguments of these functions should actually be (void *). The type has been left uncorrected for strict compatibility with System V. PORTABILITY
These routines emulate the System V forms library. They were not supported on Version 7 or BSD versions. AUTHORS
Juergen Pfeifer. Manual pages and adaptation for new curses by Eric S. Raymond. form_fieldtype(3X)
All times are GMT -4. The time now is 06:47 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy