Sponsored Content
Top Forums UNIX for Dummies Questions & Answers How do I merge multiple columns into one column? Post 302745799 by Vnguyen on Tuesday 18th of December 2012 05:27:09 AM
Old 12-18-2012
Question How do I merge multiple columns into one column?

Hi all,

I'm looking for a way to merge multiple columns (from one file) into a single column in an output file.

The file I have looks somewhat like this:

Code:
@HWI-ST212	1:N:0	AGTCCTACCGGGAGT	+	@@@DDDDDHHHHHII
@HWI-ST212	1:N:0	CGTTTAAAAATTTCT	+	@;@B;DDDDH?:F;F
@HWI-ST212	1:N:0	TCGGAGATTCCGTAC	+	???DDDDDDDDDDII
@HWI-ST212	1:N:0	GGATATAGGCGATCT	+	@@@DDDDDFFFFFII

I'd like data from each line in the input file to appear in subsequent lines in the output file, like this:

Code:
@HWI-ST212
1:N:0
AGTCCTACCGGGAGT
+
@@@DDDDDHHHHHII
@HWI-ST212
1:N:0
CGTTTAAAAATTTCT
+
@;@B;DDDDH?:F;F
@HWI-ST212
1:N:0
TCGGAGATTCCGTAC
+
???DDDDDDDDDDII
@HWI-ST212
1:N:0
GGATATAGGCGATCT
+
@@@DDDDDFFFFFII

Does anybody know how to do this?

I'm rather a newbie, any help would be appreciated Smilie

Thanks.
 

10 More Discussions You Might Find Interesting

1. UNIX for Advanced & Expert Users

merge two column multiple files into one

Hi I have multiple files each with two columns and I need to combine all those file into a tab delimited file. (multiple entry with same name separated by a comma) The content of the files are as follows: --- file1.txt: name var1 aaa xx aaa gg bbb yy ddd zz --- file2.txt ... (8 Replies)
Discussion started by: mary271
8 Replies

2. Shell Programming and Scripting

How to merge multiple rows into single row if first column matches ?

Hi, Can anyone suggest quick way to get desired output? Sample input file content: A 12 9 A -0.3 2.3 B 1.0 -4 C 34 1000 C -111 900 C 99 0.09 Output required: A 12 9 -0.3 2.3 B 1.0 -4 C 34 1000 -111 900 99 0.09 Thanks (3 Replies)
Discussion started by: cbm_000
3 Replies

3. Shell Programming and Scripting

Merge two columns from two files into one if another column matches

I have two text files that look something like this: A:B:C 123 D:E:F 234 G:H:I 345 J:K:L 123 M:N:O 456 P:Q:R 567 A:B:C 456 D:E:F 567 G:H:I 678 J:K:L 456 M:N:O 789 P:Q:R 890 I want to find the line where the first column matches and then combine the second columns into a single... (8 Replies)
Discussion started by: pbluescript
8 Replies

4. Shell Programming and Scripting

Multiple file merge by column

Hello all, I am quite new in linux shell scripting and I have this issue. I ve got some files including measurements taken every 10minutes for a whole day. File name format is: 00.00, 00.10, 00.20,....23.50 File structure is: x | y | temperature x and y is the same in all files (same... (12 Replies)
Discussion started by: atzounis
12 Replies

5. UNIX for Dummies Questions & Answers

Merge columns from multiple files

Hi all, I've searched the web for a long time trying to figure out how to merge columns from multiple files. I know paste will append columns like so: paste file1 file2 file3 file4 file5 ... But this becomes inconvenient when you want to append a large number of files into a single file. ... (2 Replies)
Discussion started by: torchij
2 Replies

6. Shell Programming and Scripting

Merge records based on multiple columns

Hi, I have a file with 16 columns and out of these 16 columns 14 are key columns, 15 th is order column and 16th column is having information. I need to concate the 16th column based on value of 1-14th column as key in order of 15th column. Here are the example file Input File (multiple... (3 Replies)
Discussion started by: Ravi Agrawal
3 Replies

7. Shell Programming and Scripting

Merge columns from multiple files

Hello and Good day I have a lot of files with same number of rows and columns.$2 and $3 are the same in all files . I need to merge $2,$3,$6 from first file and $6 from another files. File1: $1 $2 $3 $4 $5 $6... (8 Replies)
Discussion started by: ali.seifaddini
8 Replies

8. Shell Programming and Scripting

Seperated by columns, merge in a file, sort them on common column

Hi All, I have 4 files in below format. I took them as an example. File 1: Cut from position 1-4 then 6-7 then 8-14 then rest left and make them as columns in one new file. Inserting character H to the initial of all line like HCTOT. CTOT 456787897 Low fever CTOR 556712345 High fever... (2 Replies)
Discussion started by: Mannu2525
2 Replies

9. UNIX for Beginners Questions & Answers

Merge multiple columns into one using cat

I will like to merge several files using 'cat', but I observe the output is not consistent. the merge begins at the last line of the first file. file1.txt: 1234 1234 1234 file2.txt: aaaa bbbb cccc dddd cat file1.txt file2.txt > file3.txt file3.txt: 1234 1234 1234aaaa bbbb cccc... (13 Replies)
Discussion started by: geomarine
13 Replies

10. Shell Programming and Scripting

Join and merge multiple files with duplicate key and fill void columns

Join and merge multiple files with duplicate key and fill void columns Hi guys, I have many files that I want to merge: file1.csv: 1|abc 1|def 2|ghi 2|jkl 3|mno 3|pqr file2.csv: (5 Replies)
Discussion started by: yjacknewton
5 Replies
ORIGINATOR(1gmt)					       Generic Mapping Tools						  ORIGINATOR(1gmt)

NAME
originator - Associate seamounts with hotspot point sources SYNOPSIS
originator [infile(s)] -Estage_file -Fhs_file [ -C ] [ -Dd_km ] [ -H[i][nrec] ] [ -L[flag] ] [ -Nupper_age ] [ -Qr/t ] [ -S[n_hs] ] [ -T ] [ -V ] -Wmaxdist ] [ -Z ] [ -:[i|o] ] [ -bi[s|S|d|D[ncol]|c[var1/...]] ] DESCRIPTION
originator reads (longitude, latitude, height, radius, crustal_age) records from infiles [or standard input] and uses the given Absolute Plate Motion (APM) stage poles and the list of hotspot locations to determine the most likely origin (hotspot) for each seamount. It does so by calculating flowlines back in time and determining the closest approach to all hotspots. The output consists of the input records with four additional fields added for each of the n_hs closest hotspots. The four fields are the hotspot id (e.g., HWI), the stage id of the flowline segment that came closest, the pseudo-age of the seamount, and the closest distance to the hotspot (in km). See option -: on how to read (latitude, longitude,height, radius, crustal_age) files. No space between the option flag and the associated arguments. Use upper case for the option flags and lower case for modifiers. infile(s) Seamount data file(s) to be analyzed. If not given, standard input is read. -E Give file with rotation parameters. This file must contain one record for each rotation; each record must be of the following for- mat: lon lat tstart [tstop] angle [ khat a b c d e f g df ] where tstart and tstop are in Myr and lon lat angle are in degrees. tstart and tstop are the ages of the old and young ends of a stage. If -C is set then a total reconstruction rotation is expected and tstop is implicitly set to 0 and should not be specified in the file. If a covariance matrix C for the rotation is available it must be specified in a format using the nine optional terms listed in brackets. Here, C = (g/khat)*[ a b d; b c e; d e f ] which shows C made up of three row vectors. If the degrees of free- dom (df) in fitting the rotation is 0 or not given it is set to 10000. Blank lines and records whose first column contains # will be ignored. -F Give file with hotspot locations. This file must contain one record for each hotspot to be considered; each record must be of the following format: lon lat hs_abbrev hs_id r t_off t_on create fit plot name E.g., for Hawaii this may look like 205 20 HWI 1 25 0 90 Y Y Y Hawaii Most applications only need the first 4 columns which thus represents the minimal hotspot information record type. The abbreviation may be maximum 3 characters long. The id must be an integer from 1-32. The positional uncertainty of the hotspot is given by r (in km). The t_off and t_on variables are used to indicate the active time-span of the hotspot. The create, fit, and plot indicators are either Y or N and are used by some programs to indicate if the hotspot is included in the ID-grids used to determine rotations, if the hotspot chain will be used to determine rotations, and if the hotspot should be included in various plots. The name is a 32-character maximum text string with the full hotspot name. Blank lines and records whose first column contains # will be ignored. OPTIONS
-C Expect Total Reconstruction Rotations rather than Forward Stage Rotations [Default]. File format is similar to the stage pole for- mat except that the tstart column is not present (assumed to be 0 Ma). -D Sets the flowline sampling interval in km. [Default is 5]. -H Input file(s) has header record(s). If used, the default number of header records is N_HEADER_RECS. Use -Hi if only input data should have header records [Default will write out header records if the input data have them]. Blank lines and lines starting with # are always skipped. -L Output closest approach for nearest hotspot only (ignores -S). Choose -Lt for (time, dist, z) [Default], -Lw for (omega, dist, z), and -Ll for (lon, lat, time, dist, z). Normally, dist is in km; use upper case modifiers TWL to get dist in spherical degrees. -N Set the maximum age to extend the oldest stage back in time [no extension]. -Q INput files only has (x,y,z); specify constant values for r,t that will be implied for each record. -S Set the number of closest hotspots to report [Default is 1]. -T Truncate seamount ages exceeding the upper age set with -N [no truncation]. -V Selects verbose mode, which will send progress reports to stderr [Default runs "silently"]. -W Only report those seamounts whose flowlines came within maxdist to any hotspot [Default reports all seamounts]. -Z Use the hotspot ID number rather than the name tag in output records. -: Toggles between (longitude,latitude) and (latitude,longitude) input and/or output. [Default is (longitude,latitude)]. Append i to select input only or o to select output only. [Default affects both]. -bi Selects binary input. Append s for single precision [Default is d (double)]. Uppercase S or D will force byte-swapping. Option- ally, append ncol, the number of columns in your binary input file if it exceeds the columns needed by the program. Or append c if the input file is netCDF. Optionally, append var1/var2/... to specify the variables to be read. [Default is 5 input columns]. EXAMPLES
To find the likely (hotspot) origins of the seamounts represented by the (x,y,z,r,tc) points in the file seamounts.d, using the DC85.d Euler poles and the pac_hs.d list of possible hotspots, and report the 2 most likely hotspot candidates for each seamount, run originator seamounts.d -S2 -EDC85.d -Fpac_hs.d > origins.d COORDINATES
Data coordinates are assumed to be geodetic and will automatically be converted to geocentric before spherical rotations are performed. We convert back to geodetic coordinates for output. Note: If your data already are geocentric, you can avoid the conversion by using --ELLIP- SOID=sphere. SEE ALSO
GMT(1), project(1), grdrotater(1), grdspotter(1), mapproject(1), backtracker(1), hotspotter(1) REFERENCES
Wessel, P., 1999, "Hotspotting" tools released, EOS Trans. AGU, 80(29), p. 319. GMT 4.5.7 15 Jul 2011 ORIGINATOR(1gmt)
All times are GMT -4. The time now is 07:28 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy