Sponsored Content
Full Discussion: merge text files
Operating Systems AIX merge text files Post 302266861 by Franklin52 on Thursday 11th of December 2008 07:34:05 AM
Old 12-11-2008
If you have the 'HEADER' at the first line and 'TRAILER' at the last line in all your files you can delete the those lines after merging the files with:

Code:
awk -v var=`wc -l < file` 'NR>1 && /HEADER/ || NR<var && /TRAILER/{next}{print}' file > newfile

First we use a variable var wich is the number of the last line (wc -l < file).
Now we print every line except the line with HEADER if it isn't the first line and the line with TRAILER if it isn't the last line.

Regards
 

9 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Is there any non graphical tool that make selective merge between text files?

whitout using awk / sad and so on? (3 Replies)
Discussion started by: umen
3 Replies

2. Shell Programming and Scripting

Merge text files while combining the multiple header/trailer records into one each.

Situation: Our system currently executes a job (COBOL Program) that generates an interface file to be sent to one of our vendors. Because this system processes information for over 100,000 employees/retirees (and growing), we'd like to multi-thread the job into processing-groups in order to... (4 Replies)
Discussion started by: oordonez
4 Replies

3. Shell Programming and Scripting

Have several text files and want to merge into a single

Hello, I have several files that begin with db. in my directory and I would like to first take it from a specific word starting from $TTL until the end of the contents then do the same all the way down the directory then merge them into one txt file. Is this possible? I am using cygwin with... (4 Replies)
Discussion started by: richsark
4 Replies

4. Shell Programming and Scripting

merge two text files of different size on common index

I have two text files. text file 1: ID filePath col1 col2 col3 1 10584588.mol 269.126 190.958 23.237 2 10584549.mol 281.001 200.889 27.7414 3 10584511.mol 408.824 158.316 29.8561 4 10584499.mol 245.632 153.241 25.2815 5 10584459.mol ... (8 Replies)
Discussion started by: LMHmedchem
8 Replies

5. Shell Programming and Scripting

Merge the multiple text files into one file

Hi All, I am trying to merge all the text files into one file using below snippet cat /home/Temp/Test/Log/*.txt >> all.txt But it seems it is not working. I have multiple files like Output_ServerName1.txt, Output_ServreName2.txt I want to merge each file into one single file and... (6 Replies)
Discussion started by: sharsour
6 Replies

6. Shell Programming and Scripting

Need to merge multiple text files vertically and place comma between fields

Hello expert friends, I'm writing a script to capture stats using sar and stuck up at report generation. I have around 10 files in a directory and need to merge them all vertically based on the time value of first column (output file should have only one time value) and insert comma after... (6 Replies)
Discussion started by: prvnrk
6 Replies

7. Shell Programming and Scripting

Merge and Sort tabular data from different text files

I have 42 text files; each containing up to 34 lines with following structure; file1 H-01 23 H-03 5 H-05 9 H-02 14 . . file2 H-01 17 H-02 43 H-04 7 H-05 8 H-03 7 . . file3 (6 Replies)
Discussion started by: Syeda Sumayya
6 Replies

8. UNIX for Dummies Questions & Answers

Merge two text files (oh no, not again!)

Hello, I'm new to this forum. I have always made good use of all the wise hints shown here. But this time I'm struggling with an issue that is driving me crazy. I have two text files, I have to merge them based on the first column, resulting file must contain all record from the first file... (4 Replies)
Discussion started by: emare
4 Replies

9. UNIX for Dummies Questions & Answers

Merge two text files by two fields and mixed output

Hello, I'm back again looking for your precious help- This time I need to merge two text files with matching two fields, output only common records with mixed output. Let's look at the example: FILE1 56153;AAA0708;3;TEST1TEST1; 89014;BBB0708;3;TEST2TEST2; 89014;BBB0708;4;TEST3TEST3; ... (7 Replies)
Discussion started by: emare
7 Replies
PR(1)                                                              User Commands                                                             PR(1)

NAME
pr - convert text files for printing SYNOPSIS
pr [OPTION]... [FILE]... DESCRIPTION
Paginate or columnate FILE(s) for printing. With no FILE, or when FILE is -, read standard input. Mandatory arguments to long options are mandatory for short options too. +FIRST_PAGE[:LAST_PAGE], --pages=FIRST_PAGE[:LAST_PAGE] begin [stop] printing with page FIRST_[LAST_]PAGE -COLUMN, --columns=COLUMN output COLUMN columns and print columns down, unless -a is used. Balance number of lines in the columns on each page -a, --across print columns across rather than down, used together with -COLUMN -c, --show-control-chars use hat notation (^G) and octal backslash notation -d, --double-space double space the output -D, --date-format=FORMAT use FORMAT for the header date -e[CHAR[WIDTH]], --expand-tabs[=CHAR[WIDTH]] expand input CHARs (TABs) to tab WIDTH (8) -F, -f, --form-feed use form feeds instead of newlines to separate pages (by a 3-line page header with -F or a 5-line header and trailer without -F) -h, --header=HEADER use a centered HEADER instead of filename in page header, -h "" prints a blank line, don't use -h"" -i[CHAR[WIDTH]], --output-tabs[=CHAR[WIDTH]] replace spaces with CHARs (TABs) to tab WIDTH (8) -J, --join-lines merge full lines, turns off -W line truncation, no column alignment, --sep-string[=STRING] sets separators -l, --length=PAGE_LENGTH set the page length to PAGE_LENGTH (66) lines (default number of lines of text 56, and with -F 63). implies -t if PAGE_LENGTH <= 10 -m, --merge print all files in parallel, one in each column, truncate lines, but join lines of full length with -J -n[SEP[DIGITS]], --number-lines[=SEP[DIGITS]] number lines, use DIGITS (5) digits, then SEP (TAB), default counting starts with 1st line of input file -N, --first-line-number=NUMBER start counting with NUMBER at 1st line of first page printed (see +FIRST_PAGE) -o, --indent=MARGIN offset each line with MARGIN (zero) spaces, do not affect -w or -W, MARGIN will be added to PAGE_WIDTH -r, --no-file-warnings omit warning when a file cannot be opened -s[CHAR], --separator[=CHAR] separate columns by a single character, default for CHAR is the <TAB> character without -w and 'no char' with -w. -s[CHAR] turns off line truncation of all 3 column options (-COLUMN|-a -COLUMN|-m) except -w is set -S[STRING], --sep-string[=STRING] separate columns by STRING, without -S: Default separator <TAB> with -J and <space> otherwise (same as -S" "), no effect on column options -t, --omit-header omit page headers and trailers; implied if PAGE_LENGTH <= 10 -T, --omit-pagination omit page headers and trailers, eliminate any pagination by form feeds set in input files -v, --show-nonprinting use octal backslash notation -w, --width=PAGE_WIDTH set page width to PAGE_WIDTH (72) characters for multiple text-column output only, -s[char] turns off (72) -W, --page-width=PAGE_WIDTH set page width to PAGE_WIDTH (72) characters always, truncate lines, except -J option is set, no interference with -S or -s --help display this help and exit --version output version information and exit AUTHOR
Written by Pete TerMaat and Roland Huebner. REPORTING BUGS
GNU coreutils online help: <http://www.gnu.org/software/coreutils/> Report pr translation bugs to <http://translationproject.org/team/> COPYRIGHT
Copyright (C) 2017 Free Software Foundation, Inc. License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>. This is free software: you are free to change and redistribute it. There is NO WARRANTY, to the extent permitted by law. SEE ALSO
Full documentation at: <http://www.gnu.org/software/coreutils/pr> or available locally via: info '(coreutils) pr invocation' GNU coreutils 8.28 January 2018 PR(1)
All times are GMT -4. The time now is 03:48 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy