P.S.: Looking forward to see another solution from Don
Hi stomp,
To be honest, it looks to me like you have put a lot of work into this thread and I haven't really checked out your code. When I see that the last line in a file isn't being processed and I see a comment about the data being processed being on a PC, I have to wonder if the data is in DOS text format (with no line terminator on the last line). If there is no line terminator on the final line, the behavior of sort and awk is unspecified. I don't use perl enough to know how it deals with partial lines and its behavior is not specified by the standards.
If the date format in the files is YYYY/MM/DD, then the dates can be compared (without conversions) just by performing string comparisons on field 1 values. But, if the date format is YYYY/DD/MM, some kind of conversion will be required before timestamps can be compared unless we know that all lines in the files being processed are for a single date.
And, for the record, two or more files can be read in parallel in awk using the normal record processing input methods for one of the files and statements of the form:
where filename is a variable name or constant string specifying the name of another file and variable_name is a variable that will be assigned the contents of the next line from that file. The return value from any call to getline is 1 for successful input, zero for end-of-file, and −1 for an error.
Hi, i've two files (file1, file2) i want to take value (in column1) and search in file2 if the they match print the value from file2.
this is what i have so far.
awk 'FILENAME=="file1"{ arr=$1 }
FILENAME=="file2"
{print $0}
' file1 file2 (2 Replies)
I have very limited coding skills but I'm wondering if someone could help me with this. There are many threads about matching strings in two files, but I have no idea how to add a column from one file to another based on a matching string.
I'm looking to match column1 in file1 to the number... (3 Replies)
I have a file containing texts and indexes. I need the text between (and including ) INDEX and number "1" alone in line. I have managed this:
awk '/INDEX/,/1$/{if (!/1$/)print}' file1.txt
It works for all indexes.
And then I have second file with years and indexes per year, one per line... (3 Replies)
Hi.
How can we print those rows of file2 which are mentioned in file1. first character of file1 is a row number.. for eg
file1
1:abc
3:ghi
6:pqr
file2
a abc
b def
c ghi
d jkl
e mno
f pqr
... (6 Replies)
I have two files.
File 1 is a two-column index file, e.g.
comp11084_c0_seq6:130-468(-) comp12746_c0_seq3:140-478(+)
comp11084_c0_seq3:201-539(-) comp12746_c0_seq2:191-529(+)
File 2 is a sequence file with headers named with the same terms that populate file 1. ... (1 Reply)
I have a list of IDs in file1 and a list of sequences in file2. I can print sequences from file2, but I'm asking for help in printing the sequences in the same order as the IDs appear in file1.
file1:
EN_comp12952_c0_seq3:367-1668
ES_comp17168_c1_seq6:1-864
EN_comp13395_c3_seq14:231-1088... (5 Replies)
Hi, I wanted to add each row of file2.txt to entire length of file1.txt given the sample data below and save it as new file. Any idea how to efficiently do it. Thank you for any help.
input file
file1.txt file2.txt
140 30 200006 141 32
140 32 200006 142 33
140 35 200006 142... (5 Replies)
I am trying to use awk to find all the $2 values in file2 which is ~30MB and tab-delimited, that are between $2 and $3 in file1 which is ~2GB and tab-delimited.
I have just found out that I need to use $1 and $2 and $3 from file1 and $1 and $2of file2 must match $1 of file1 and be in the range... (6 Replies)
This is a question that is related to one I had last August when I was trying to sort/merge two files by millsecond time column (in this case column 6).
The script (below) that helped me last august by RudiC solved the puzzle of sorting/merging two files by time, except it gets lost when the... (0 Replies)
Discussion started by: aachave1
0 Replies
LEARN ABOUT DEBIAN
birthday
birthday(1) General Commands Manual birthday(1)NAME
birthday - warn about upcoming birthdays and other events
SYNOPSIS
birthday [-w|-c] [-f file] [-W defwarn] [-M maxwarn] [-m minwarn] [-l lines] [-p weeks] [-d total] [-i width]
DESCRIPTION
The birthday command reads a file, by default ~/.birthdays, which gives a list of events in the near future (see section FILE FORMAT for
details). It can then produce either a list of events which are coming up within the next few weeks, or a text-based calendar with a few
lines for each day.
OPTIONS -w Display a list of upcoming events. This is the default.
-c Display a calendar, designed to be piped to lpr(1).
-f file
Read the events from file rather than ~/.birthdays. If file is a single hyphen, read the events from the standard input (usually
the terminal).
List Options
-W warn
Warn warn days in advance, for entries that have no w flag (see FILE FORMAT). If this switch is not specified, it defaults to 21
days.
-M max Warn at most max days in advance. This overrides any flag given in the file.
-m min Warn at least min days in advance. This overrides any flag given in the file.
Calendar Options
-l lines
Print lines lines for every day.
-p weeks
Print weeks weeks on every page of the calendar. If set to 0, the default, disables page breaks.
-d days
Print the calendar for up to days days in advance.
-i width
Print the calendar width characters wide. This affects the length of the lines separating each day, and the point at which events
will be word-wrapped.
FILE FORMAT
Each line beginning with a hash sign, `#', is a comment and will be ignored. Lines beginning with an ampersand, `&', are directives. Cur-
rently there is only one such directive, &include file, which reads in a seperate file from your .birthdays file. file should be given
with an absolute path, which should not use the tilde notation to specify your home directory.
Any other line specifies the name of a person or event, followed by an equals sign and a date (DD/MM, DD/MM/YY or DD/MM/YYYY, where the
form DD/MM/YY is assumed to give a date in the 20th century and is now deprecated), and finally some extra options. These options are:
bd This line is a birthday (the default). The year, if given, should be when the person was born. A line designated as a birthday will
produce output like Erin has a birthday in 3 days' time or Jemima is 3 in 2 weeks' time.
ann This line is an anniversary. The year, if given, should be the year in which the thing happened, producing output like Pen exploded
3 years ago tomorrow given a line such as Pen exploded=12/09/93 ann.
ev This line is an event of some sort. If a year is given, the text will be displayed in that year only; otherwise, it will be dis-
played every year. The remaining time is simply appended to the text; for instance, the input Easter=7/4/1996 ev would give rise to
the text Easter in 1 week's time.
wn Warn n days in advance of the date, rather than the default of 21 days or the number given with the -W flag.
todate The event lasts until date, which should be in the same format as for the date of the event.
fordays
The event lasts for days days.
DATE SPECIFICATION
The file format documented here handles dates in a couple of slightly non-standard ways. Firstly, the dates are given in British format of
DD/MM/YYYY, as opposed to the more normal US format MM/DD/YYYY.
Secondly, dates with a two-digit year are assumed to be in the 20th century (19xx), rather than taking the standard convention of assuming
all two-digit years less than 70 are in the 21st century. This is for reasons of compatibility with older data files, since many people
have birthdays before 1970, and the program was written before I came across the Y2K issues. :-( You should probably avoid this format.
EXAMPLE
Joe Blow=25/04/1974
FILES
~/.birthdays
Your default birthdays file.
SEE ALSO cal(1)BUGS
Both the "features" in the DATE SPECIFICATION section could be construed as bugs, and are mostly present for backwards compatibility.
The calendar mode should be a seperate program.
The program cannot warn more than one year in advance of anything.
AUTHOR
Andy Mortimer <andy.mortimer@zetnet.co.uk>
birthday(1)