Sponsored Content
Full Discussion: print selected rows with awk
Top Forums Shell Programming and Scripting print selected rows with awk Post 302137823 by radoulov on Thursday 27th of September 2007 05:51:19 AM
Old 09-27-2007
Code:
awk 'NR==8,NR==2459{if(NR%7==1)print}' filename

Use nawk or /usr/xpg4/bin/awk on Solaris.
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Cutting rows after a selected point

I have a log file from which I want to cut out the ten lines assoictiated to my search requirment (cust_ref #). The cust_ref number will be on te first line and the update information will be on the following ten lines (which dosen't linking data to grep on). Using a script I would like to... (4 Replies)
Discussion started by: nhatch
4 Replies

2. Shell Programming and Scripting

return number of rows selected

Hi all, i am doing a perl script to read from a db. I am able to retrieve the rows, but i am unable to return the number of rows selected. i tried $selectedrows = $sth->numrows; i got the error msg: Can't locate object method "numrows" via package "DBI::st" i changed it to $selectedrows =... (7 Replies)
Discussion started by: new2ss
7 Replies

3. Shell Programming and Scripting

shell script(Preferably awk or sed) to print selected number of columns from each row

Hi Experts, The question may look very silly by seeing the title, but please have a look at it clearly. I have a text file where the first 5 columns in each row were supposed to be attributes of a sample(like sample name, number, status etc) and the next 25 columns are parameters on which... (3 Replies)
Discussion started by: ks_reddy
3 Replies

4. Shell Programming and Scripting

trying to print selected fields of selected lines by AWK

I am trying to print 1st, 2nd, 13th and 14th fields of a file of line numbers from 29 to 10029. I dont know how to put this in one code. Currently I am removing the selected lines by awk 'NR==29,NR==10029' File1 > File2 and then doing awk '{print $1, $2, $13, $14}' File2 > File3 Can... (3 Replies)
Discussion started by: ananyob
3 Replies

5. Shell Programming and Scripting

To extract selected rows

Hi, I have two files Input1.txt and Input2.txt and i need to have a output with selected lines starting with the values present in Input2.txt. For example: Input1.txt:... (5 Replies)
Discussion started by: bhas
5 Replies

6. UNIX for Dummies Questions & Answers

Awk: Print out overlapping chunks of file - rows 0-20,10-30,20-40 etc.

First time poster, but the forum has saved my bacon more times than... Lots. Anyway, I have a text file, and wanted to use Awk (or any other sensible program) to print out overlapping sections, or arbitrary length. To describe by example, for file 1 2 3 4 5 etc... I want the out put... (3 Replies)
Discussion started by: matfald
3 Replies

7. Shell Programming and Scripting

awk command to print only selected rows in a particular column specified by column name

Dear All, I have a data file input.csv like below. (Only five column shown here for example.) Data1,StepNo,Data2,Data3,Data4 2,1,3,4,5 3,1,5,6,7 3,2,4,5,6 5,3,5,5,6 From this I want the below output Data1,StepNo,Data2,Data3,Data4 2,1,3,4,5 3,1,5,6,7 where the second column... (4 Replies)
Discussion started by: ks_reddy
4 Replies

8. Shell Programming and Scripting

Print rows with value zero or less than zero using awk

I tried this. It working fine for small tables. But it is giving values greater than zero in a big file with 8556 columns. Does any one know why ? awk 'FNR == 1{print;next}{for(i=8556;i<=NF;i++) if($i <= 0){print;next}}' input (5 Replies)
Discussion started by: quincyjones
5 Replies

9. UNIX for Beginners Questions & Answers

Reading and copying a selected rows

Dear All, I have a data file input.res like below. (Only six column shown here for example.) Sequence of first column starting from 1 to 148. Input file 1 Q0 9_August_2014_Entertainment2 0 20.14967806339729 BM25b1.0 1 Q0 13_October_2012_Page323 1 20.134224346765738 BM25b1.0 1 Q0... (2 Replies)
Discussion started by: imranrasheedamu
2 Replies

10. Shell Programming and Scripting

Awk- Indexing a list of numbers in file2 to print certain rows in file1

Hi Does anyone know of an efficient way to index a column of data in file2 to print the coresponding row in file1 which corresponds to the data in file2 AND 30 rows preceding and after the row in file1. For example suppose you have a list of numbers in file2 (single column) as follows:... (6 Replies)
Discussion started by: Geneanalyst
6 Replies
PG_COPY_FROM(3) 														   PG_COPY_FROM(3)

pg_copy_from - Insert records into a table from an array

SYNOPSIS
bool pg_copy_from (resource $connection, string $table_name, array $rows, [string $delimiter], [string $null_as]) DESCRIPTION
pg_copy_from(3) inserts records into a table from $rows. It issues a COPY FROM SQL command internally to insert records. PARAMETERS
o $connection - PostgreSQL database connection resource. o $table_name - Name of the table into which to copy the $rows. o $rows - An array of data to be copied into $table_name. Each value in $rows becomes a row in $table_name. Each value in $rows should be a delimited string of the values to insert into each field. Values should be linefeed terminated. o $delimiter - The token that separates values for each field in each element of $rows. Default is TAB. o $null_as - How SQL NULL values are represented in the $rows. Default is N ("\N"). RETURN VALUES
Returns TRUE on success or FALSE on failure. EXAMPLES
Example #1 pg_copy_from(3) example <?php $db = pg_connect("dbname=publisher") or die("Could not connect"); $rows = pg_copy_to($db, $table_name); pg_query($db, "DELETE FROM $table_name"); pg_copy_from($db, $table_name, $rows); ?> SEE ALSO
pg_copy_to(3). PHP Documentation Group PG_COPY_FROM(3)
All times are GMT -4. The time now is 05:55 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy