Sponsored Content
Top Forums Shell Programming and Scripting Adding a new column in a file with other existing columns Post 302454926 by Pratik4891 on Monday 20th of September 2010 09:32:01 AM
Old 09-20-2010
Adding a new column in a file with other existing columns

Hi All ,
Kindly help me with this soln
Code:
awk '{printf "%s %7s \n", $1,$c}' infile

where
value of variable c I am externally giving input
But executing the above command shows all the columns of infile where as I want only 1st column of infile and 2nd column should print value c

Last edited by jim mcnamara; 09-20-2010 at 11:43 AM.. Reason: code tags please
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Adding header to an existing file

Dear All, I need to add a header of one line to an already existing file. I know that it can be achieved by the following: echo "Header" > newfile cat file1 >> newfile But my problem is that file is huge and there is no space for creating a new file every time. Is there a way that I can... (5 Replies)
Discussion started by: shash
5 Replies

2. Shell Programming and Scripting

Need Help for Adding Three new columns in existing file from fatching data from file

not required this time (36 Replies)
Discussion started by: Sandeep_Malik
36 Replies

3. Shell Programming and Scripting

how to add a new column in an existing file

Hi guys, Please help me if u have some solution. I have a file with three columns separated by ':' - INPUT_FILE C416722_2 : calin Dirigent : Dirigent AC4174_6 : Jac : cal_co TC4260_5 : [no : lin kite BC426302_1 : [no : calin Dirigent lin JC426540_3 : lin Pymo_bin : calin TC428_3 : no7... (4 Replies)
Discussion started by: sam_2921
4 Replies

4. Shell Programming and Scripting

Adding file to an existing tar

Hi Friends, I want to know the command to add a new file in a existing tar file. For Ex: I have a tar file file1.tar with the contents one.txt two.txt three.txt Now I need to add file four.txt to this existing tar file, how can I do it? Thanks in advance (4 Replies)
Discussion started by: mr_manii
4 Replies

5. Shell Programming and Scripting

Adding existing set of records in the same file

I have a file with 50,000 records in it, i have a requirement to use the same 50,000 records and add them 4 times to the same file to make a total of 200,000 records. I was wondering how to do this using ksh. Any help is greatly appreciated. (2 Replies)
Discussion started by: vpv0002
2 Replies

6. Shell Programming and Scripting

Awk to add columns from a file into an existing file

Hi! I would need some help to add the last two columns of one file into another file using awk (or something similar). For example, I have: file 1: file 2: car book day root lag bar look pay boot tag tar took may moot sag I want to have:... (5 Replies)
Discussion started by: coconaza
5 Replies

7. Shell Programming and Scripting

Adding a new column to an existing one

I have a data file that looks like this: 0.01 1 3822 4.97379915032e-14 4.96982253992e-09 0 0.01 3822 1 4.97379915032e-14 4.96982253992e-09 0 0.01 2 502 0.00993165137406 993.165137406 0 0.01 502 2 0.00993165137406 993.165137406 0 0.01 4 33 0.00189645523539 189.645523539 0 0.01 33 4... (3 Replies)
Discussion started by: kayak
3 Replies

8. Shell Programming and Scripting

Adding columns with values dependent on existing columns

Hello I have a file as below chr1 start ref alt code1 code2 chr1 18884 C CAAAA 2 0 chr1 135419 TATACA T 2 0 chr1 332045 T TTG 0 2 chr1 453838 T TAC 2 0 chr1 567652 T TG 1 0 chr1 602541 ... (2 Replies)
Discussion started by: plumb_r
2 Replies

9. UNIX for Dummies Questions & Answers

Solaris - Filter columns in text file and adding new column

Hello, I am very now to this, hope you can help, I am looking into editing a file in Solaris, with dinamic collums (lenght varies) and I need 2 things to be made, the fist is to filter the first column and third column from the file bellow file.txt, and create a new file with the 2 filtered... (8 Replies)
Discussion started by: jpbastos
8 Replies

10. Shell Programming and Scripting

Matching column then append to existing File as new column

Good evening I have the below requirements, as I am not an experts in Linux/Unix and am looking for your ideas how I can do this. I have file called file1 and file2. I need to get the second column which is text1_random_alphabets and find that in file 2, if it's exists then print the 3rd... (4 Replies)
Discussion started by: mychbears
4 Replies
SAMPLE1D(l)															       SAMPLE1D(l)

NAME
sample1d - Resampling of 1-D data sets SYNOPSIS
sample1d infile [ -Fl|a|c ] [ -H[nrec] ] [ -Ixinc ] [ -M[flag] ] [ -Nknotfile ] [ -Sxstart ] [ -Tx-col] [ -V ] [ -bi[s][n] ] [ -bo[s][n] ] DESCRIPTION
sample1d reads a multi-column ASCII [or binary] data set from file [or standard input] and resamples the timeseries/profile at locations where the user needs the values. The user must provide the column number of the independent (monotonically increasing or decreasing) vari- able. Equidistant or arbitrary sampling can be selected. All columns are resampled based on the new sampling interval. Several interpola- tion schemes are available. infile This is a multi-column ASCII [of binary, see -b] file with one column containing the independent variable (which must be monotoni- cally in/de-creasing) and the remaining columns holding misc. data values. If no file is provided, sample1d reads from standard input. OPTIONS
No space between the option flag and the associated arguments. -F Choose from l (Linear), a (Akima spline), and c (natural cubic spline) [Default is -Fa]. You may change the default interpolant; see INTERPOLANT in your .gmtdefaults file. -H Input file(s) has Header record(s). Number of header records can be changed by editing your .gmtdefaults file. If used, GMT default is 1 header record. -I xinc defines the sampling interval. [Default is the separation between the first and second abcissa point in the infile] -M Multiple segment file. Segments are separated by a record whose first character is flag. [Default is '>']. -N knotfile is an optional ASCII file with the x locations where the data set will be resampled in the first column -S For equidistant sampling, xstart indicates the location of the first output value. [Default is the smallest even multiple of xinc inside the range of infile] -T Sets the column number of the independent variable [Default is 0 (first)]. -V Selects verbose mode, which will send progress reports to stderr [Default runs "silently"]. -bi Selects binary input. Append s for single precision [Default is double]. Append n for the number of columns in the binary file(s). [Default is 2 (or at least the number of columns implied by -T]. -bo Selects binary output. Append s for single precision [Default is double]. EXAMPLES
To resample the file profiles.tdgmb, which contains (time,distance,gravity,magnetics,bathymetry) records, at 1km equidistant intervals using Akima's spline, try' sample1d profiles.tdgmb -I1 -Fa -T1 > profiles_equi_d.tdgmb To resample the file depths.dt at positions listed in the file grav_pos.dg, using a cubic spline for the interpolation, try sample1d depths.dt -Ngrav_pos.dg -Fc > new_depths.dt SEE ALSO
gmt(1gmt), filter1d(1gmt) 1 Jan 2004 SAMPLE1D(l)
All times are GMT -4. The time now is 10:02 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy