Sponsored Content
Top Forums UNIX for Dummies Questions & Answers Adding a column to a text file with row numbers Post 302746939 by Scrutinizer on Thursday 20th of December 2012 07:37:37 AM
Old 12-20-2012
On your path this would put the line numbers at the end:
Code:
sed = test1.txt | sed 'N;s/\(.*\)\n\(.*\)/\2 \1/'

An awk alternative would be:
Code:
awk '{print $0,NR}' test1.txt

 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Changing the column for a row in a text file and adding another row

Hi, I want to write a shell script which increments a particular column in a row from a text file and then adds another row below the current row with the incremented value . For Eg . if the input file has a row : abc xyz lmn 89 lm nk o p I would like the script to create something like... (9 Replies)
Discussion started by: aYankeeFan
9 Replies

2. UNIX for Advanced & Expert Users

Adding a column of numbers

Hello, I have a file, and one column has both positive and negative numbers. Does anyone know how I can calculate the total of all the values (i.e, +ve and -ve). eg: col1 col2 col3 data 23 data data 76 data data -30 data Thanks Khoom (1 Reply)
Discussion started by: Khoomfire
1 Replies

3. Shell Programming and Scripting

Adding a column to a text based on file name

Dear all, Does anyone know how I could to add a column of numbers (1s, or 2s, or..., or 6s) to two-column text files (tab-delimited), where the specific number to be added varies as a function of the file naming? Currently, each of my text files has two columns, so the column with the... (12 Replies)
Discussion started by: rlapate
12 Replies

4. UNIX for Dummies Questions & Answers

How do you delete cells from a space delimited text file given row and column number?

How do you delete cells from a space delimited text file given row and column number? Letś say the row number is r and the column number is c. Thanks! (5 Replies)
Discussion started by: evelibertine
5 Replies

5. UNIX for Dummies Questions & Answers

Appending a column of numbers in ascending order to a text file

I have a text file where I want to append a column of numbers in ascending orders. Input: 57 abc 25 def 32 ghi 54 jkl Output:57 abc 57 abc 1 25 def 2 32 ghi 3 54 jkl 4 How do I go about doing that? Thanks! (11 Replies)
Discussion started by: evelibertine
11 Replies

6. Shell Programming and Scripting

Adding row of numbers

is there another way of doing the below: echo "7 3 8 2 2 1 3 83.4 8.2 4 8 73 90.5" | bc shell is bash. os is linux and sunos. bc seems to have an issue with long range of numbers (12 Replies)
Discussion started by: SkySmart
12 Replies

7. UNIX for Dummies Questions & Answers

Adding Column Of Numbers

Hello. Trying to add a column of numbers and combine the 1st and 2nd fields as uniq with the new total. This works to add the numbers but can't figure an easy was to combine the 1st and 2nd column as the list is very long. awk '{s+=$3} END {print s}' bird dog 300 bird dog 100 cat clown 200... (1 Reply)
Discussion started by: jimmyf
1 Replies

8. Shell Programming and Scripting

Adding a timestamp every N row in another column

Hi, i have a raw output file like this 167,63.50 167,63.50 168,63.68 166,63.68 168,63.68 I would like to add every each N rows (for example 60) and in a third column , a timestamp using the command date +"%H:%M"how can i do it with one single command ? Thank you !! (5 Replies)
Discussion started by: Board27
5 Replies

9. Shell Programming and Scripting

Column to row and position data in a text file

Hi everyone.. I have a list of values in a file... a, b, c, 1, 2, 3, aaaa, bbbbb, I am interested in converting this column to a row.. "text",aaaa, bbbb a,1 (7 Replies)
Discussion started by: manihi
7 Replies

10. Shell Programming and Scripting

Print every alternate column in row in a text file

Hi, I have a comma separated file. I would like to print every alternate columns into a new row. Example input file: Name : John, Age : 30, DOB : 30-Oct-2018 Example output: Name,Age,DOB John,30,30-Oct-2018 (3 Replies)
Discussion started by: Lini
3 Replies
SPI_MODIFYTUPLE(3)					  PostgreSQL 9.2.7 Documentation					SPI_MODIFYTUPLE(3)

NAME
SPI_modifytuple - create a row by replacing selected fields of a given row SYNOPSIS
HeapTuple SPI_modifytuple(Relation rel, HeapTuple row, int ncols, int * colnum, Datum * values, const char * nulls) DESCRIPTION
SPI_modifytuple creates a new row by substituting new values for selected columns, copying the original row's columns at other positions. The input row is not modified. ARGUMENTS
Relation rel Used only as the source of the row descriptor for the row. (Passing a relation rather than a row descriptor is a misfeature.) HeapTuple row row to be modified int ncols number of column numbers in the array colnum int * colnum array of the numbers of the columns that are to be changed (column numbers start at 1) Datum * values new values for the specified columns const char * Nulls which new values are null, if any (see SPI_execute_plan for the format) RETURN VALUE
new row with modifications, allocated in the upper executor context; NULL only if row is NULL On error, SPI_result is set as follows: SPI_ERROR_ARGUMENT if rel is NULL, or if row is NULL, or if ncols is less than or equal to 0, or if colnum is NULL, or if values is NULL. SPI_ERROR_NOATTRIBUTE if colnum contains an invalid column number (less than or equal to 0 or greater than the number of column in row) PostgreSQL 9.2.7 2014-02-17 SPI_MODIFYTUPLE(3)
All times are GMT -4. The time now is 08:48 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy