Sponsored Content
Full Discussion: Multi File processing
Top Forums Shell Programming and Scripting Multi File processing Post 302156557 by Franklin52 on Tuesday 8th of January 2008 01:30:56 PM
Old 01-08-2008
Code:
awk 'BEGIN{FS=OFS=","}
FNR==NR{arr[$2]=$1;next}
$4 in arr{print $4,arr[$4],$1}
' file1 file2

Regards
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

multi-file multi-edit

Good day! I am trying to learn how to use the "sed" editor, to perform multiple edits on multiple files in multiple directories. I have one script that tries to call up each file and process it according to the edits listed in a second script. I am using a small input text to test these, at... (12 Replies)
Discussion started by: kielitaide
12 Replies

2. UNIX for Dummies Questions & Answers

Multi User Multi Task

Dear Experts Why we always hear that unix operating system is Multi User and Multi task. What does these two means. I have looked at some books and documents but couldn't find aclear explenation. Can we say Windows operating system is also multi user and multi task?? Thanks for your help in... (6 Replies)
Discussion started by: Reza Nazarian
6 Replies

3. Shell Programming and Scripting

multi file editing in vi

Hi all Some yeras ago (1994) I had a utility that bundled up multiple files into a big file with a seperator lines. Automatically loaded this temp file into vi - which allowed you to edit all the files. then when you :wq or ZZ vi it saved all the files bak to their appropriate file names and got... (0 Replies)
Discussion started by: ricl999
0 Replies

4. Shell Programming and Scripting

AWK Multi-Line Records Processing

I am an Awk newbie and cannot wrap my brain around my problem: Given multi-line records of varying lengths separated by a blank line I need to skip the first two lines of every record and extract every-other line in each record unless the first line of the record has the word "(CONT)" in the... (10 Replies)
Discussion started by: RacerX
10 Replies

5. Shell Programming and Scripting

Multi-copying a file

Hello there, I am writting a scrip with in shell (#!/bin/sh) and I need to copy 5 times the same file into different names: cp xsec.1.11 xsec.1.12 cp xsec.1.11 xsec.1.13 cp xsec.1.11 xsec.1.14 cp xsec.1.11 xsec.1.15 cp xsec.1.11 xsec.1.16 and I have to do that for several file.... (6 Replies)
Discussion started by: jolecanard
6 Replies

6. Shell Programming and Scripting

Multi-line filtering based on multi-line pattern in a file

I have a file with data records separated by multiple equals signs, as below. ========== RECORD 1 ========== RECORD 2 DATA LINE ========== RECORD 3 ========== RECORD 4 DATA LINE ========== RECORD 5 DATA LINE ========== I need to filter out all data from this file where the... (2 Replies)
Discussion started by: Finja
2 Replies

7. Shell Programming and Scripting

How to substract selective values in multi row, multi column file (using awk or sed?)

Hi, I have a problem where I need to make this input: nameRow1a,text1a,text2a,floatValue1a,FloatValue2a,...,floatValue140a nameRow1b,text1b,text2b,floatValue1b,FloatValue2b,...,floatValue140b look like this output: nameRow1a,text1b,text2a,(floatValue1a - floatValue1b),(floatValue2a -... (4 Replies)
Discussion started by: nricardo
4 Replies

8. Programming

awk processing / Shell Script Processing to remove columns text file

Hello, I extracted a list of files in a directory with the command ls . However this is not my computer, so the ls functionality has been revamped so that it gives the filesizes in front like this : This is the output of ls command : I stored the output in a file filelist 1.1M... (5 Replies)
Discussion started by: ajayram
5 Replies

9. Programming

Multi head/multi window hello world

I am trying to write a large X app. I have successfully modified my xorg.conf to setup 4 monitors on an NVIDIA Quatro5200. I am trying to modify a simple hello world application to open a window on three of the four monitors. depending on the changes to loop the window creation section and event... (2 Replies)
Discussion started by: advorak
2 Replies

10. Shell Programming and Scripting

Help with reformat single-line multi-fasta into multi-line multi-fasta

Input File: >Seq1 ASDADAFASFASFADGSDGFSDFSDFSDFSDFSDFSDFSDFSDFSDFSDFSD >Seq2 SDASDAQEQWEQeqAdfaasd >Seq3 ASDSALGHIUDFJANCAGPATHLACJHPAUTYNJKG ...... Desired Output File >Seq1 ASDADAFASF ASFADGSDGF SDFSDFSDFS DFSDFSDFSD FSDFSDFSDF SD >Seq2 (4 Replies)
Discussion started by: patrick87
4 Replies
DateTimeX::Easy(3pm)					User Contributed Perl Documentation				      DateTimeX::Easy(3pm)

NAME
DateTimeX::Easy - Parse a date/time string using the best method available VERSION
version 0.089 SYNOPSIS
# Make DateTimeX object for "now": my $dt = DateTimeX::Easy->new("today"); # Same thing: my $dt = DateTimeX::Easy->new("now"); # Uses ::F::Natural's coolness (similar in capability to Date::Manip) my $dt = DateTimeX::Easy->new("last monday"); # ... but in 1969: my $dt = DateTimeX::Easy->new("last monday", year => 1969); # ... at the 100th nanosecond: my $dt = DateTimeX::Easy->new("last monday", year => 1969, nanosecond => 100); # ... in US/Eastern: (This will NOT do a timezone conversion) my $dt = DateTimeX::Easy->new("last monday", year => 1969, nanosecond => 100, timezone => "US/Eastern"); # This WILL do a proper timezone conversion: my $dt = DateTimeX::Easy->new("last monday", year => 1969, nanosecond => 100, timezone => "US/Pacific"); $dt->set_time_zone("US/Eastern"); # Custom DateTimeX ability: my $dt = DateTimeX::Easy->new("last second of last month"); $dt = DateTimeX::Easy->new("last second of first month of last year"); $dt = DateTimeX::Easy->new("last second of first month of 2000"); DESCRIPTION
DateTimeX::Easy makes DateTime object creation quick and easy. It uses a variety of DateTime::Format packages to do the bulk of the parsing, with some custom tweaks to smooth out the rough edges (mainly concerning timezone detection and selection). PARSING
Currently, DateTimeX::Easy will attempt to parse input in the following order: DateTime - Is the input a DateTime object? ICal - Was DT::F::ICal able to parse the input? DateParse - Was DT::F::DateParse able to parse the input? A caveat, I actually use a modified version of DateParse in order to avoid DateParse's default timezone selection. Natural - Was DT::F::Natural able to parse the input? Since this module barfs pretty loudly on strange input, we use a silent $SIG{__WARN__} to hide errors. Flexible - Was DT::F::Flexible able to parse the input? This step also looks at the string to see if there is any timezone information at the end. DateManip - Was DT::F::DateManip able to parse the input? DateManip isn't very nice with preserving the input timezone, but it's here as a last resort. "last second of first month of year of 2005" DateTimeX::Easy also provides additional parsing and transformation for input like: "first day of last month" "last day of last month" "last day of this month" "last day of next month" "last second of first month of last year" "ending day of month of 2007-10-02" "last second of first month of year of 2005" "last second of last month of year of 2005" "beginning day of month of 2007-10-02" "last month of year of 2007" It will look at each sequence of "<first|last> of <period>" and do ->add, ->subtract, and ->truncate operations on the parsed DateTime object Also, It's best to be as explicit as possible; the following will work: "last month of 2007" "last second of last month of 2005" "beginning day of 2007-10-02" This won't, though: "last day of 2007" You'll have to do this instead: "last day of year of 2007" The reason is that the date portion is opaque to the parser. It doesn't know whether it has "2007" or "2007-10" or "now" as the last input. To fix this, you can give a hint to the parser, like "<period> of <date/time>" (as in "year of 2007" above). WARNING: This feature is still somewhat new, so there may be bugs lurking about. Please forward failing tests/scenarios. METHODS
DateTimeX::Easy->new( ... ) DateTimeX::Easy->parse( ... ) DateTimeX::Easy->parse_date( ... ) DateTimeX::Easy->parse_datetime( ... ) DateTimeX::Easy->date( ... ) DateTimeX::Easy->datetime( ... ) DateTimeX::Easy->new_date( ... ) DateTimeX::Easy->new_datetime( ... ) Parse the given date/time specification using ::F::Flexible or ::F::Natural and use the result to create a DateTime object. Returns a DateTime object. You can pass the following in: parse # The string or DateTime object to parse. year # A year to override the result of parsing month # A month to override the result of parsing day # A day to override the result of parsing hour # A hour to override the result of parsing minute # A minute to override the result of parsing second # A second to override the result of parsing truncate # A truncation parameter (e.g. year, day, month, week, etc.) time_zone # - Can be: timezone # * A timezone (e.g. US/Pacific, UTC, etc.) tz # * A DateTime special timezone (e.g. floating, local) # # - If neither "tz", "timezone", nor "time_zone" is set, then it'll use whatever is parsed. # - If no timezone is parsed, then the default is floating. # - If the given timezone is different from the parsed timezone, # then a time conversion will take place (unless "soft_time_zone_conversion" is set). # - Either "time_zone", "timezone", "tz" will work (in that order), with "time_zone" having highest precedence # - See below for examples! soft_time_zone_conversion # Set this flag to 1 if you don't want the time to change when a given timezone is # different from a parsed timezone. For example, "10:00 UTC" soft converted to # PST8PDT would be "10:00 PST8PDT". time_zone_if_floating # The value of this option should be a valid timezone. If this option is set, then a DateTime object # with a floating timezone has it's timezone set to the value. default_time_zone # Same as "time_zone_if_floating" ambiguous # Set this flag to 0 if you want to disallow ambiguous input like: # "last day of 2007" or "first minute of April" # This will require you to specify them as "last day of year of 2007" and "first minute of month of April" # instead. This flag is 1 (false) by default. ... and anything else that you want to pass to the DateTime->new constructor If "truncate" is specificied, then DateTime->truncate will be run after object creation. Furthermore, you can simply pass the value for "parse" as the first positional argument of the DateTimeX::Easy call, e.g.: # This: DateTimeX::Easy->new("today", year => 2008, truncate => "hour"); # ... is the same as this: DateTimeX::Easy->new(parse => "today", year => 2008, truncate => "hour"); Timezone processing can be a little complicated. Here are some examples: DateTimeX::Easy->parse("today"); # Will use a floating timezone DateTimeX::Easy->parse("2007-07-01 10:32:10"); # Will ALSO use a floating timezone DateTimeX::Easy->parse("2007-07-01 10:32:10 US/Eastern"); # Will use US/Eastern as a timezone DateTimeX::Easy->parse("2007-07-01 10:32:10"); # Will use the floating timezone DateTimeX::Easy->parse("2007-07-01 10:32:10", time_zone_if_floating => "local"); # Will use the local timezone DateTimeX::Easy->parse("2007-07-01 10:32:10 UTC", time_zone => "US/Pacific"); # Will convert from UTC to US/Pacific my $dt = DateTime->now->set_time_zone("US/Eastern"); DateTimeX::Easy->parse($dt); # Will use US/Eastern as the timezone DateTimeX::Easy->parse($dt, time_zone => "floating"); # Will use a floating timezone DateTimeX::Easy->parse($dt, time_zone => "US/Pacific", soft_time_zone_conversion => 1); # Will use US/Pacific as the timezone with NO conversion # For example, "22:00 US/Eastern" will become "22:00 PST8PDT" DateTimeX::Easy->parse($dt)->set_time_zone("US/Pacific"); # Will use US/Pacific as the timezone WITH conversion # For example, "22:00 US/Eastern" will become "19:00 PST8PDT" DateTimeX::Easy->parse($dt, time_zone => "US/Pacific"); # Will ALSO use US/Pacific as the timezone WITH conversion EXPORT
parse( ... ) parse_date( ... ) parse_datetime( ... ) date( ... ) datetime( ... ) new_date( ... ) new_datetime( ... ) Same syntax as above. See above for more information. MOTIVATION
Although I really like using DateTime for date/time handling, I was often frustrated by its inability to parse even the simplest of date/time strings. There does exist a wide variety of DateTime::Format::* modules, but they all have different interfaces and different capabilities. Coming from a Date::Manip background, I wanted something that gave me the power of ParseDate while still returning a DateTime object. Most importantly, I wanted explicit control of the timezone setting at every step of the way. DateTimeX::Easy is the result. THANKS
Dave Rolsky and crew for writing DateTime SEE ALSO
DateTime DateTime::Format::Natural DateTime::Format::Flexible DateTime::Format::ICal DateTime::Format::DateManip DateTime::Format::ParseDate Date::Manip SOURCE
You can contribute or fork this project via GitHub: <http://github.com/robertkrimen/datetimex-easy/tree/master> git clone git://github.com/robertkrimen/datetimex-easy.git DateTimeX-Easy ACKNOWLEDGEMENTS
COPYRIGHT &; LICENSE Copyright 2007 Robert Krimen, all rights reserved. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. AUTHOR
Robert Krimen <robertkrimen@gmail.com> COPYRIGHT AND LICENSE
This software is copyright (c) 2010 by Robert Krimen. This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself. perl v5.10.1 2010-08-24 DateTimeX::Easy(3pm)
All times are GMT -4. The time now is 07:08 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy