Sponsored Content
Top Forums Shell Programming and Scripting How to combine 2 files into 1 file with 2 columns Post 302532073 by bartus11 on Sunday 19th of June 2011 04:59:59 PM
Old 06-19-2011
Code:
paste -d" " inputfile1.txt inputfile2.txt > outputfile.txt

PS: those are not spaces that separate the columns, but TABs Smilie
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

combine text files into one file

I need to write a shell script which combines/joins 3 text files into one file. Do i put the txt files in the same folder as my script? Here is what i have: #!/bin/bash file1=$1 file2=$2 file3=$3 out="output.txt" count=0 if then echo "$(basename $0) file1 file2 file3" ... (3 Replies)
Discussion started by: zzthejimzz
3 Replies

2. Shell Programming and Scripting

Combine multiple columns from multiple files

Hi there, I was wondering if someone can help me with this. I am trying the combine multiple columns from multiple files into one file. Example file 1: c0t0d0 c0t2d0 # hostname vgname c0t0d1 c0t2d1 # hostname vgname c0t0d2 c0t2d2 # hostname vgname c0t1d0 c0t3d0 # hostname vgname1... (5 Replies)
Discussion started by: martva
5 Replies

3. Shell Programming and Scripting

get data from files combine them to a file

hi people; this is my file1.txt:192.168.1.1 192.168.1.2 192.168.1.3 192.168.1.4 ... this is my file2.txt:portnames usernames maxusercap ... i want to write to file3.txt:l ./getports 192.168.1.1 'get all;l+;get . portnames;l-' l ./getports 192.168.1.1 'get all;l+;get . usernames;l-'... (4 Replies)
Discussion started by: gc_sw
4 Replies

4. UNIX for Dummies Questions & Answers

combine the values from the first two columns within a file

Hello everybody, I have a text file containing 10,000 rows and 5000 columns. The values are separated by a tab. Ex. file_ex.ped 1 mike 0 0 2 1 A A G G C T A G 1 jack 0 0 2 2 T A G T C A A C 1 Mary 0 0 1 2 A T G C A T G C ... I would like a out put file 1 mike 0 0 2 1 AA GG CT AG 1... (7 Replies)
Discussion started by: Unilearn
7 Replies

5. UNIX for Dummies Questions & Answers

How to combine 2 files with 6 columns?

This may seem obvious but I am having problems doing this as columns get converted to rows when i try to write a script. I have 2 files text1.txt and text2.txt each of which have 6 columns of numbers separated by a space. I need to combine the 2 files so that the output file text3.txt maintains... (2 Replies)
Discussion started by: tgoldstone
2 Replies

6. Shell Programming and Scripting

Combine columns from multiple files

Can anybody help on the script to combine/concatenate columns from multiple files input1 4 135 5 185 6 85 11 30 16 72 17 30 21 52 22 76 input2 2 50 4 50 6 33 8 62 10 25 12 46 14 42 15 46output (2 Replies)
Discussion started by: sdf
2 Replies

7. UNIX for Dummies Questions & Answers

Combine columns from 100 files with same structure

Hi, I have a bunch of files with the following format. PUR.1.9 30910 0.024 0.926 0.050 36587 0.024 0.927 0.049 91857 0.023 0.928 0.049 105797 0.024 0.927 0.049 146659 0.024 0.927 0.049 152695 0.024 0.927 0.049 192118 0.022 0.930 0.048 193310 0.018 0.936 0.046 PUR.2.9 30910 0.028... (6 Replies)
Discussion started by: genehunter
6 Replies

8. Shell Programming and Scripting

Combine columns from many files but keep them aligned in columns-shorter left column issue

Hello everyone, I searched the forum looking for answers to this but I could not pinpoint exactly what I need as I keep having trouble. I have many files each having two columns and hundreds of rows. first column is a string (can have many words) and the second column is a number.The files are... (5 Replies)
Discussion started by: isildur1234
5 Replies

9. Shell Programming and Scripting

Combine data out of 3 files into one new file

Hi, How can I combine the data of of three files into one new file? I try to give as much informations as possible. The three existing files are called file1 file2 and file3 the new file should named output_combined. The size of the files will be around 900 words/lines each .. but always... (5 Replies)
Discussion started by: MyMemberName
5 Replies

10. Shell Programming and Scripting

Combine Columns

Input NJ090237_0263_GRP,NJ090237_0263_VIEW,NJ090237_0263_PSGRP,NJ090237_0263_GOLD_CSGRP,06E:0_08E:0_09E:0_11E:0,0CE5 NJ090237_0264_GRP,NJ090237_0263_VIEW,NJ090237_0264_PSGRP,NJ090237_0263_GOLD_CSGRP,06E:0_08E:0_09E:0_11E:0,0CE5... (7 Replies)
Discussion started by: greycells
7 Replies
GMTSTITCH(1gmt) 					       Generic Mapping Tools						   GMTSTITCH(1gmt)

NAME
gmtstitch - Join line segments whose end points match within tolerance SYNOPSIS
gmtstitch [ infiles ] [ -C[closed] ] [ -D[template] ] [ -H[i][nrec] ] [ -L[linkfile] ] [ -Q[template] ] [ -Tcutoff[m|c|e|E|k|K][/nn_dist] ] [ -V ] [ -:[i|o] ] [ -b[i|o][s|S|d|D[ncol]|c[var1/...]] ] [ -bo[s|S|d|D[ncol]|c[var1/...]] ] [ -m[i|o][flag] ] DESCRIPTION
gmtstitch reads one or more data files (which may be multisegment files; see -m) and examines the coordinates of the end points of all line segments. If a pair of end points are identical or closer to each other than the specified separation tolerance then the two line segments are joined into a single segment. The process repeats until all the remaining endpoints no longer pass the tolerance test; the resulting segments are then written out to standard output. It it is not clear what the separation tolerance should be then use -L to get a list of all separation distances and analyze them to determine a suitable cutoff. file(s) One of more data files. If none are supplied then we read standard input. OPTIONS
-C Write all the closed polygons to closed [gmtstitch_closed.d] and all other segments as they are to stdout. No stitching takes place. Use -Tcutoff to set a minimum separation [0], and if cutoff is > 0 then we also close the polygons on output. -D For multiple segment data, dump each segment to a separate output file [Default writes a multiple segment file to stdout]. Append a format template for the individual file names; this template must contain a C format specifier that can format an integer argument (the segment number); this is usually %d but could be %8.8d which gives leading zeros, etc. Optionally, it may also contain the for- mat %c before the integer; this will then be replaced by C (closed) or O (open) to indicate segment type. [Default is gmt- stitch_segment_%d.d]. Note that segment headers will be written in either case. For composite segments, a generic segment header will be written and the segment headers of individual pieces will be written out as comments to make it possible to identify where the stitched pieces came from. -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 Writes the link information to the specified file [links.d]. For each segment we write the original segment id, and for the begin- ning and end point of the segment we report the id of the closest segment, whether it is the beginning (B) or end (E) point that is closest, and the distance between those points in units determined by -T. -Q Used with -D to a list file with the names of the individual output files. Optionally, append a filename template for the individ- ual file names; this template may contain a C format specifier that can format an character (C or O for closed or open, respec- tively). [Default is gmtstitch_list.d]. -T Specifies the separation tolerance in the data coordinate units [0]. Append m or c for minutes or seconds, or e or k for meters or km (implies -fg using use flat Earth approximation. Use E or K for exact geodesic distances; however. if the current ELLIPSOID is Sphere then spherical great circle distances are used. If two lines has endpoints that are closer than this cutoff they will be joined. Optionally, append /nn_dist which adds the requirement that a link will only be made if the second closest connection exceeds the nn_dist. The latter distance is assumed to be in the same units as cutoff. -V Selects verbose mode, which will send progress reports to stderr [Default runs "silently"]. -: 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 2 input columns]. -bo Selects binary output. Append s for single precision [Default is d (double)]. Uppercase S or D will force byte-swapping. Option- ally, append ncol, the number of desired columns in your binary output file. [Default is same as input]. -f Special formatting of input and/or output columns (time or geographical data). Specify i or o to make this apply only to input or output [Default applies to both]. Give one or more columns (or column ranges) separated by commas. Append T (absolute calendar time), t (relative time in chosen TIME_UNIT since TIME_EPOCH), x (longitude), y (latitude), or f (floating point) to each column or column range item. Shorthand -f[i|o]g means -f[i|o]0x,1y (geographic coordinates). -m Multiple segment file(s). Segments are separated by a special record. For ASCII files the first character must be flag [Default is '>']. For binary files all fields must be NaN and -b must set the number of output columns explicitly. By default the -m setting applies to both input and output. Use -mi and -mo to give separate settings to input and output. ASCII FORMAT PRECISION
The ASCII output formats of numerical data are controlled by parameters in your .gmtdefaults4 file. Longitude and latitude are formatted according to OUTPUT_DEGREE_FORMAT, whereas other values are formatted according to D_FORMAT. Be aware that the format in effect can lead to loss of precision in the output, which can lead to various problems downstream. If you find the output is not written with enough pre- cision, consider switching to binary output (-bo if available) or specify more decimals using the D_FORMAT setting. EXAMPLES
To combine the digitized multisegment lines segment_*.d (whose coordinates are in cm) into as few complete lines as possible, assuming the end points slop could be up to 0.1 mm, run gmtstitch segment_*.d -Tf0.1 -m > new_segments.d To combine the digitized segments in the multisegment file my_lines.d (whose coordinates are in lon,lat) into as few complete lines as pos- sible, assuming the end points slop could be up to 150 m, and write the complete segments to separate files called Map_segment_0001.dat, Map_segment_0002.dat, etc., run gmtstitch my_lines.d -Tf0.15k -m -DMap_segment_%4.4d.dat SEE ALSO
GMT(1), mapproject(1) GMT 4.5.7 15 Jul 2011 GMTSTITCH(1gmt)
All times are GMT -4. The time now is 10:39 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy