05-16-2012
can send me please the code integrated that before processing all files validate the headers - number of columns is equal in all.
Only creates or process the new merged file if the number of columns is equal in boths files.
10 More Discussions You Might Find Interesting
1. Shell Programming and Scripting
Hi,
I am trying to read 2 files and writing to the 3rd file if I find the same elements in 2 files. my first file is
1 0 kb12124819 766409 1.586e-01
1 0 kb17160939 773886 8.674e-01
1 0 kb4475691 836671 8.142e-01
1 0 ... (2 Replies)
Discussion started by: ezhil01
2 Replies
2. Shell Programming and Scripting
hi,
i am facing a problem in merging two files using awk,
the problem is as stated below,
file1:
A|B|C|D|E|F|G|H|I|1
M|N|O|P|Q|R|S|T|U|2
AA|BB|CC|DD|EE|FF|GG|HH|II|1
....
....
....
file2 :
1|Mn|op|qr (2 Replies)
Discussion started by: shashi1982
2 Replies
3. Shell Programming and Scripting
Hello All,
I have a folder containing few files. Each & every file contain only 1 column.
I want to combine only column of all the files through GAWK, separate them by a delimiter and store it to a new file.
So basically using GAWK, I want to combine '$1' of all files, separate them by a... (11 Replies)
Discussion started by: paragkalra
11 Replies
4. Shell Programming and Scripting
Given are File A and File B
File A has for example 5 lines:
AAA
BBB
CCC
DDD
EEE
File B has 3 lines:
111
222
333
How can i merge A and B into:
111
222
333
AAA (first line from A)
then a new file: (4 Replies)
Discussion started by: Y-T
4 Replies
5. Shell Programming and Scripting
Hi Guys,
After windows died on my netbook I installed Lubuntu and discovered Gawk about a month ago. After using Excel for 10+ years I'm amazed how quick and easily Gawk can process data but I'm stuck with a little problem merging data from multiple lines.
I'm an SEO Consultant and provide... (9 Replies)
Discussion started by: Jamesfirst
9 Replies
6. Shell Programming and Scripting
Hi ,
This might be the stupidest question I am asking, but I am struck with this problem. I am trying to merge 2 files, file1 has header and file2 has contents. while I merge them , it merges from the 1st line of file1.
for ex: file1
col1|col2|col3|
file2
123|234|456|... (2 Replies)
Discussion started by: rashmisb
2 Replies
7. Shell Programming and Scripting
Hi all,
I'm very, very new to scripting (let alone SHELL) and was wondering if anyone could help me out as I seem to be in a spot of bother.
I collect data (.dat files) which are automatically seperated into several sub directories, so the file paths I'm reading in at the moment would be... (11 Replies)
Discussion started by: gd9629
11 Replies
8. Shell Programming and Scripting
Hi,
My requirement is,there is a directory location like:
:camp/current/
In this location there can be different flat files that are generated in a single day with same header and the data will be different, differentiated by timestamp, so i need to verify how many files are generated... (10 Replies)
Discussion started by: srikanth_sagi
10 Replies
9. Shell Programming and Scripting
Dear Gents,
Please I need your help... I need small script :) to do the following.
I have a thousand of files in a folder produced daily.
I need first to merge all files called. txt (0009.txt, 0010.txt, 0011.txt) and and to output a resume of all information on 2 separate files in csv... (14 Replies)
Discussion started by: jiam912
14 Replies
10. Shell Programming and Scripting
Dear Frens,
I have two files and need to merge into one file. Like
File_1:
Field1 Field2
1 4
File_2:
Field1 Field2
3 5
I need one single output as
File_1:
Field1 Field2
1 4
3 5
This means taking header from either file. (8 Replies)
Discussion started by: manisha_singh
8 Replies
pr(1) General Commands Manual pr(1)
Name
pr - print files
Syntax
pr [ options ] [ files ]
Description
The command prints the named files on the standard output. If file is designated by a minus sign (-), or if no files are specified the
command assumes standard input. By default, the listing is separated into pages, each headed by the page number, a date and time, and the
name of the file.
By default, columns are of equal width, separated by at least one space. Lines that do not fit are truncated. However, if the -s option is
used, lines are not truncated and columns are separated by the separation character.
If the standard output is associated with a terminal, error messages are withheld until has finished printing.
Options
The following options can be used singly or in combination:
-a Prints multi-column output across the page.
-b Prints blank headers.
-d Double-spaces the output.
-eck Expands input tabs to character positions k+1, 2*k+1, 3*k+1,... n*k+1. If k is 0 or is omitted, tabs are set at every eighth posi-
tion. Tab characters in the input are expanded into the appropriate number of spaces. The default for c (any non-digit character)
is the tab character; therefore, if c is given, it is treated as the input tab character.
-f Uses form-feed character for new pages. The default is to use a sequence of line-feeds. The -f option causes the command to pause
before beginning the first page if the standard output is associated with a terminal.
-h Uses the next argument as the header to be printed instead of the file name.
-ick Replaces white space in output by inserting tabs to character positions k+1, 2*k+1, 3*k+1,...n*k+1. If k is 0 or is omitted, tabs
are set at every eighth position. The default for c (any non-digit character) is the tab character; therefore, if c is given, it
is treated as the input tab character.
+k Begins printing with page k (default is 1).
-k Produces k-column output (default is 1). The -e and -i options are assumed for multi-column output.
-lk Sets the length of a page to k lines. The default is 66 lines.
-m Merges and prints all files simultaneously, one per column (overrides the -k, and -a options).
-nck Numbers lines. The default for k is 20. The number occupies the first k+1 character positions of each column of normal output or
each line of -m output. If c, which is any non-digit character is given, it is appended to the line number to separate it from
whatever follows. The default for c is a tab.
-ok Offsets each line by k character positions (default is 0). The number of character positions per line is the sum of the width and
offset.
-p Pauses before beginning each page if the output is directed to a terminal. The command rings the bell at the terminal and awaits a
carriage return.
-r Suppresses diagnostic reports on failure to open files.
-sc Separates columns by the single character c instead of by the appropriate number of spaces (default for c is a tab).
-t Suppresses the five-line identifying header and the five-line trailer normally supplied for each page. The -t option causes the
command to quit printing after the last line of each file without spacing to the end of the page.
-wk Sets the width of a line to k character positions. The default is 72 for equal-width multi-column output; otherwise there is no
limit.
Examples
Print file1 and file2 as a double-spaced, three-column listing with the heading: file list.
pr -3dh "file list" file1 file2
Write file1 on file2, expanding tabs to columns 10, 19, 28, 37,...:
pr -e9 -t <file1>file2
Files
/dev/tty* to suspend messages
See Also
cat(1)
pr(1)