I need a script to get the common lines from two files with a criteria that if the first two columns match then I keep the maximum value of the 3rd column.(tab separated columns)
Sample input:
file1:
file 2:
sample output:
This is being done for all the files in the same format in a directory. I have the script without considering the 3rd column condition:
Please help. Thanks in advance.
Last edited by vgersh99; 06-28-2010 at 12:07 PM..
Reason: code tags, please!
Hi,
I have one situation. I have some 6-7 no. of files in one directory & I have to extract all the lines which exist in all these files. means I need to extract all common lines from all these files & put them in a separate file.
Please help. I know it could be done with the help of... (11 Replies)
Hi! I have a large set of pairs of text files (each pair in their own subdirectory) and each pair shares head/tail (a couple of first and last lines) but differs in the middle part. I need to delete the heads/tails and keep only the middle portions in which they differ. The lengths of heads/tails... (1 Reply)
Hello guys,
I need a script to get the common lines from two files with a criteria that if the first two columns match then I keep the maximum value of the 5th column.(tab separated columns) . 3rd and 4th columns corresponds to the row which has highest value for the 5th column.
Sample... (2 Replies)
Hello everyone
A few years Ago the user radoulov posted a fancy solution for a problem, which was about finding common lines (gene variation names) between multiple samples (files). The code was:
awk 'END {
for (R in rec) {
n = split(rec, t, "/")
if (n > 1)
dup = dup ?... (5 Replies)
Thanks everyone. I got that problem solved.
I require one more help here. (Yes, UNIX definitely seems to be fun and useful, and I WILL eventually learn it for myself. But I am now on a different project and don't really have time to go through all the basics. So, I will really appreciate some... (6 Replies)
Dear All,
I have 2 files. If field 1, 2, 4 and 5 matches in both file1 and file2, I want to print the whole line of file1 and file2 one after another in my output file.
File1:
sc2/80 20 . A T 86 F=5;U=4
sc2/60 55 . G T ... (1 Reply)
Hi! I would like to comm -12 with one file and with all of the files in another folder that has a 100 files or more (that file is not in that folder) to find common text lines. I would like to have each case that they have common lines to be written to a different output file and the names of the... (6 Replies)
Could it be possible to find common lines between all of the files in one folder? Just like comm -12 . So all of the files two at a time. I would like all of the outcomes to be written to a different files, and the file names could be simply numbers - 1 , 2 , 3 etc. All of the file names contain... (19 Replies)
Hi,
A beginner one.
my input.tab (tab-separated):
h1 h2 h3 h4 h5
item1 grpA 2 3 customer1
item2 grpB 4 6 customer1
item3 grpA 5 9 customer1
item4 grpA 0 0 customer2
item5 grpA 9 1 customer2
objective:
output a file for each customer ($5) with the item number ($1) only if $2 matches... (2 Replies)
Discussion started by: beca123456
2 Replies
LEARN ABOUT ULTRIX
pr
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 Alsocat(1)pr(1)