Sponsored Content
Full Discussion: Sort a tab file with header.
Top Forums UNIX for Dummies Questions & Answers Sort a tab file with header. Post 302594176 by mary271 on Monday 30th of January 2012 05:47:37 PM
Old 01-30-2012
Sort a tab file with header.

How to sort a tab delimited file first on col1 and then on col2. Also I need to keep the header intact.

file.txt

val1 val2 val3 val4
a b c d
m n o p
e f g h
i j k l


Thanks
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Add a header to a sort file instruction

Hello, I have a header which I have to add to a sorted file, however if I use cat header sortedfile > newfile, the operation takes 2 minutes as the sorted file is over 400mb. I have noticed that when I sort the 400mb unsorted file, this only takes 14 seconds to create the output. As... (2 Replies)
Discussion started by: clarcombe
2 Replies

2. UNIX for Dummies Questions & Answers

Sort and uniq lines of a file while keeping a header line

So, I have a file that has some duplicate lines. The file has a header line that I would like to keep at the top. I could do this by extracting the header from the file, 'sort -u' the remaining lines, and recombine them. But they are quite big, so if there is a way to do it with a single... (1 Reply)
Discussion started by: Digby
1 Replies

3. Shell Programming and Scripting

sort a report file having header and footer

I am having report file with header and footer . The details in between header and footer are separated by a pipe charater. I want to sort the file by considering multiple columns in between header and footer. pls help (4 Replies)
Discussion started by: suryanarayana
4 Replies

4. Shell Programming and Scripting

[Solved] Append an header to a tab delimited file

Dear All, I would like to find an automatic way to add a given code which belong to a class at the end of the column , for example this is my input file: 0610009O20Rik V$VMYB_01 310 (+) 1 0.971 v-Myb V$EVI1_04 782 (-) 0.763 0.834 Evi-1 V$ELK1_02 1966 (-) 1 0.984 Elk-1... (4 Replies)
Discussion started by: paolo.kunder
4 Replies

5. UNIX for Dummies Questions & Answers

How to add a header to a tab delimited .txt file?

Hi, I have a tab delimited document with 18 columns. My file looks like: comp1000201_c0_seq1 comp1000201_c0 337 183.51 0.00 0.00 0.00 0.00 ---NA--- 337 0 0 - comp1000297_c0_seq1 comp1000297_c0 612 458.50 ... (1 Reply)
Discussion started by: alisrpp
1 Replies

6. UNIX for Dummies Questions & Answers

How can i sort a .txt file without loosing the header information?

Hi, I'm trying to sort 2 different .txt tab delimited files with the command line: sort -k 1b,1 inputfile > outputfile But doing that i'm also sorting the header (that ends at the end of my file). How can i sort a .txt file without sorting the header but conserving the header in the... (3 Replies)
Discussion started by: alisrpp
3 Replies

7. UNIX for Dummies Questions & Answers

Sort tab delimited file according to which rows have missing values

Hello! I have a tab delimited file with values in three columns. Some values occur in all three columns, other values are present in only one or two columns. I would like to sort the file so that rows with no missing values come first, rows with one missing values come next, and rows with two... (9 Replies)
Discussion started by: MBarrett1213
9 Replies

8. UNIX for Dummies Questions & Answers

Sort a las file keep the header as it is

I have several las files with a header and each file start Version and text and before the data starts end up with ~Ascii, then the numbers starts: ------------------------------------------------------------------------- Code: ~Version .....text.... ~Ascii 2 abc 230 1 name 1 abc ... (1 Reply)
Discussion started by: tk2000
1 Replies

9. UNIX for Dummies Questions & Answers

Sort a las file keep the header as it is

I have several las files with a header and each file start Version and text and before the data starts end up with ~Ascii, then the numbers starts: ------------------------------------------------------------------------- ~Version .....text.... ~Ascii 2 abc 230 1 name 1 abc 400 1... (17 Replies)
Discussion started by: tk2000
17 Replies

10. Shell Programming and Scripting

Sort and Split file with header and custom name

Hi, I am using SUN SOLARIS (SunOS sun4v sparc SUNW, T5240). I have a huge data file with header and trailer. This file gets used into an ETL process. ETL skips the header record (which is the first record of the file) and loads the rest of the record. The file can be delimited (comma,... (5 Replies)
Discussion started by: Saanvi1
5 Replies
MAXDB_STMT_EXECUTE(3)							 1						     MAXDB_STMT_EXECUTE(3)

maxdb_stmt_execute - Executes a prepared Query

       Procedural style

SYNOPSIS
bool maxdb_stmt_execute (resource $stmt) DESCRIPTION
Object oriented style bool maxdb_stmt::execute (void ) The maxdb_stmt_execute(3) function executes a query that has been previously prepared using the maxdb_prepare(3) function represented by the $stmt resource. When executed any parameter markers which exist will automatically be replaced with the appropiate data. If the statement is UPDATE, DELETE, or INSERT, the total number of affected rows can be determined by using the maxdb_stmt_affected_rows(3) function. Likewise, if the query yields a result set the maxdb_fetch(3) function is used. Note When using maxdb_stmt_execute(3), the maxdb_fetch(3) function must be used to fetch the data prior to preforming any additional queries. RETURN VALUES
Returns TRUE on success or FALSE on failure. EXAMPLES
Example #1 Object oriented style <?php $maxdb = new maxdb("localhost", "MONA", "RED", "DEMODB"); /* check connection */ if (maxdb_connect_errno()) { printf("Connect failed: %s ", maxdb_connect_error()); exit(); } $maxdb->query("CREATE TABLE temp.mycity LIKE hotel.city"); /* Prepare an insert statement */ $query = "INSERT INTO temp.mycity (zip, name, state) VALUES (?,?,?)"; $stmt = $maxdb->prepare($query); $stmt->bind_param("sss", $val1, $val2, $val3); $val1 = '11111'; $val2 = 'Georgetown'; $val3 = 'NY'; /* Execute the statement */ $stmt->execute(); $val1 = '22222'; $val2 = 'Hubbatown'; $val3 = 'CA'; /* Execute the statement */ $stmt->execute(); /* close statement */ $stmt->close(); /* retrieve all rows from myCity */ $query = "SELECT zip, name, state FROM temp.mycity"; if ($result = $maxdb->query($query)) { while ($row = $result->fetch_row()) { printf("%s (%s,%s) ", $row[0], $row[1], $row[2]); } /* free result set */ $result->close(); } /* remove table */ $maxdb->query("DROP TABLE temp.mycity"); /* close connection */ $maxdb->close(); ?> Example #2 Procedural style <?php $link = maxdb_connect("localhost", "MONA", "RED", "DEMODB"); /* check connection */ if (maxdb_connect_errno()) { printf("Connect failed: %s ", maxdb_connect_error()); exit(); } maxdb_query($link, "CREATE TABLE temp.mycity LIKE hotel.city"); /* Prepare an insert statement */ $query = "INSERT INTO temp.mycity (zip, name, state) VALUES (?,?,?)"; $stmt = maxdb_prepare($link, $query); maxdb_stmt_bind_param($stmt, "sss", $val1, $val2, $val3); $val1 = '11111'; $val2 = 'Georgetown'; $val3 = 'NY'; /* Execute the statement */ maxdb_stmt_execute($stmt); $val1 = '22222'; $val2 = 'Hubbatown'; $val3 = 'CA'; /* Execute the statement */ maxdb_stmt_execute($stmt); /* close statement */ maxdb_stmt_close($stmt); /* retrieve all rows from myCity */ $query = "SELECT zip, name, state FROM temp.mycity"; if ($result = maxdb_query($link, $query)) { while ($row = maxdb_fetch_row($result)) { printf("%s (%s,%s) ", $row[0], $row[1], $row[2]); } /* free result set */ maxdb_free_result($result); } /* remove table */ maxdb_query($link, "DROP TABLE temp.mycity"); /* close connection */ maxdb_close($link); ?> The above example will output something similar to: 11111 (Georgetown,NY) 22222 (Hubbatown,CA) SEE ALSO
maxdb_prepare(3), maxdb_stmt_bind_param(3). PHP Documentation Group MAXDB_STMT_EXECUTE(3)
All times are GMT -4. The time now is 04:52 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy