Sponsored Content
Full Discussion: Look up Multiple files
Top Forums Shell Programming and Scripting Look up Multiple files Post 302863709 by rramkrishnas on Tuesday 15th of October 2013 03:59:58 AM
Old 10-15-2013
Sorry for the unstructured sample output
Code:
a.txt
column1,column2, column3
1,a,1-jan-13
2,b,3-jan-13
3,c,5-jan-13
4,d,12-dec-12
5,e,11-nov-11
6,f,1-oct-13
 
b.txt
1,a,1-jan-13
2,b,3-jan-13
3,c,5-jan-13
4,f,
5,f,11-nov-11
6,f,1-oct-13

c.txt
1,1-jan-13
2,3-jan-13
3,5-jan-13
4,12-dec-12
5,11-nov-11
6,1-oct-13

Desired Output file can be in below format
 
a.column1,a.column2,a.column3,b.column2,b.column3,c.column2
1,a,1-Jan-13,a,1-Jan-13,1-Jan-13
2,b,3-Jan-13,b,3-Jan-13,3-Jan-13
3,c,5-Jan-13,c,5-Jan-13,5-Jan-13
4,d,12-Dec-12,f,,12-Dec-12
5,e,11-Nov-11,f,11-Nov-11,11-Nov-11
6,f,1-Oct-13,f,1-Oct-13,1-Oct-13

 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Using AWK: Extract data from multiple files and output to multiple new files

Hi, I'd like to process multiple files. For example: file1.txt file2.txt file3.txt Each file contains several lines of data. I want to extract a piece of data and output it to a new file. file1.txt ----> newfile1.txt file2.txt ----> newfile2.txt file3.txt ----> newfile3.txt Here is... (3 Replies)
Discussion started by: Liverpaul09
3 Replies

2. Programming

Control multiple program instances - open multiple files problem

Hello. This shouldn't be an unusual problem, but I cannot find anything about it at google or at other search machine. So, I've made an application using C++ and QtCreator. I 've made a new mime type for application's project files. My system (ubuntu 10.10), when I right click a file and I... (3 Replies)
Discussion started by: hakermania
3 Replies

3. Shell Programming and Scripting

awk, multiple files input and multiple files output

Hi! I'm new in awk and I need some help. I have a folder with a lot of files and I need that awk do something in each file and print a new file with the output. The input file name should be modified when I print the outpu files. Thanks in advance for help! :-) ciao (5 Replies)
Discussion started by: gabrysfe
5 Replies

4. Shell Programming and Scripting

Column extraction from multiple files to multiple files

I have roughly ~30 .txt files in a directory which all have unique names. These files all contain text arranged in columns separated by whitespace (example file: [#YY MM DD hh mm WDIR WSPD GST WVHT DPD APD MWD PRES ATMP WTMP DEWP VIS TIDE #yr mo dy hr mn degT m/s m/s m sec ... (5 Replies)
Discussion started by: aozgaa
5 Replies

5. UNIX for Dummies Questions & Answers

Run one script on multiple files and print out multiple files.

How can I run the following command on multiple files and print out the corresponding multiple files. perl script.pl genome.gff 1.txt > 1.gff However, there are multiples files of 1.txt, from 1----100.txt Thank you so much. No duplicate posting! Continue here. (0 Replies)
Discussion started by: grace_shen
0 Replies

6. Shell Programming and Scripting

Run one script on multiple files and print out multiple files.

How can I Run one script on multiple files and print out multiple files. FOR EXAMPLE i want to run script.pl on 100 files named 1.txt ....100.txt under same directory and print out corresponding file 1.gff ....100.gff.THANKS (4 Replies)
Discussion started by: grace_shen
4 Replies

7. Shell Programming and Scripting

Create Multiple UNIX Files for Multiple SQL Rows output

Dear All, I am trying to write a Unix Script which fires a sql query. The output of the sql query gives multiple rows. Each row should be saved in a separate Unix File. The number of rows of sql output can be variable. I am able save all the rows in one file but in separate files. Any... (14 Replies)
Discussion started by: Rahul_Bhasin
14 Replies

8. Shell Programming and Scripting

Grep strings on multiple files and output to multiple files

Hi All, I want to use egrep on multiple files and the results should be output to multiple files. I am using the below code in my shell script(working in Ksh shell). However with this code I am not attaining the desired results. #!/bin/ksh ( a="/path/file1" b="path/file2" for file in... (4 Replies)
Discussion started by: am24
4 Replies

9. Shell Programming and Scripting

Removing carriage returns from multiple lines in multiple files of different number of columns

Hello Gurus, I have a multiple pipe separated files which have records going over multiple Lines. End of line separator is \n and records going over multiple lines have <CR> as separator. below is example from one file. 1|ABC DEF|100|10 2|PQ RS T|200|20 3| UVWXYZ|300|30 4| GHIJKL|400|40... (7 Replies)
Discussion started by: dJHa
7 Replies

10. Shell Programming and Scripting

sed parser behaving strange on replacing multiple words in multiple files

I have 4000 files like $cat clus_grp_seq10_g.phy 18 1002 anig_OJJ65951_1 ATGGTTTCGCAGCGTGATAGAGAATTGTTTAGGGATGATATTCGCTCGCGAGGAACGAAGCTCAATGCTGCCGAGCGCGAGAGTCTGCTAAGGCCATATCTGCCAGATCCGTCTGACCTTCCACGCAGGCCACTTCAGCGGCGCAAGAAGGTTCCTCG aver_OOF92921_1 ... (1 Reply)
Discussion started by: sammy777888
1 Replies
Period(3)						User Contributed Perl Documentation						 Period(3)

NAME
Time::Period - A Perl module to deal with time periods. SYNOPSIS
"use Time::Period;" "$result = inPeriod($time, $period);" DESCRIPTION
The inPeriod function determines if a given time falls within a given period. inPeriod returns 1 if the time does fall within the given period, 0 if not, and -1 if inPeriod detects a malformed time or period. The time is specified as per the "time()" function, which is assumed to be the number of non-leap seconds since January 1, 1970. The period is specified as a string which adheres to the format sub-period[, sub-period...] or the string "none" or whitespace. The string "none" is not case sensitive. If the period is blank, then any time period is assumed because the time period has not been restricted. In that case, inPeriod returns 1. If the period is "none", then no time period applies and inPeriod returns 0. A sub-period is of the form scale {range [range ...]} [scale {range [range ...]}] Scale must be one of nine different scales (or their equivalent codes): Scale | Scale | Valid Range Values | Code | *******|*******|************************************************ year | yr | n where n is an integer 0<=n<=99 or n>=1970 month | mo | 1-12 or jan, feb, mar, apr, may, jun, jul, | | aug, sep, oct, nov, dec week | wk | 1-6 yday | yd | 1-365 mday | md | 1-31 wday | wd | 1-7 or su, mo, tu, we, th, fr, sa hour | hr | 0-23 or 12am 1am-11am 12noon 12pm 1pm-11pm minute | min | 0-59 second | sec | 0-59 The same scale type may be specified multiple times. Additional scales simply extend the range defined by previous scales of the same type. The range for a given scale must be a valid value in the form of v or v-v For the range specification v-v, if the second value is larger than the first value, the range wraps around unless the scale specification is year. Year does not wrap because the year is never really reset, it just increments. Ignoring that fact has lead to the dreaded year 2000 nightmare. When the year rolls over from 99 to 00, it has really rolled over a century, not gone back a century. inPeriod supports the dangerous two digit year notation because it is so rampant. However, inPeriod converts the two digit notation to four digits by prepending the first two digits from the current year. In the case of 99-1972, the 99 is translated to whatever current century it is (probably 20th), and then range 99-1972 is treated as 1972-1999. If it were the 21st century, then the range would be 1972-2099. Anyway, if v-v is 9-2 and the scale is month, September, October, November, December, January, and February are the months that the range specifies. If v-v is 2-9, then the valid months are February, March, April, May, Jun, July, August, and September. 9-2 is the same as Sep-Feb. v isn't a point in time. In the context of the hour scale, 9 specifies the time period from 9:00:00 am to 9:59:59 am. This is what most people would call 9-10. In other words, v is discrete in its time scale. 9 changes to 10 when 9:59:59 changes to 10:00:00, but it is 9 from 9:00:00 to 9:59:59. Just before 9:00:00, v was 8. Note that whitespace can be anywhere and case is not important. Note also that scales must be specified either in long form (year, month, week, etc.) or in code form (yr, mo, wk, etc.). Scale forms may be mixed in a period statement. Furthermore, when using letters to specify ranges, only the first two for week days or the first three for months are significant. January is a valid specification for jan, and Sunday is a valid specification for su. Sun is also valid for su. PERIOD EXAMPLES To specify a time period from Monday through Friday, 9am to 5pm, use a period such as wd {Mon-Fri} hr {9am-4pm} When specifing a range by using -, it is best to think of - as meaning through. It is 9am through 4pm, which is just before 5pm. To specify a time period from Monday through Friday, 9am to 5pm on Monday, Wednesday, and Friday, and 9am to 3pm on Tuesday and Thursday, use a period such as wd {Mon Wed Fri} hr {9am-4pm}, wd{Tue Thu} hr {9am-2pm} To specify a time period that extends Mon-Fri 9am-5pm, but alternates weeks in a month, use a period such as wk {1 3 5} wd {Mon Wed Fri} hr {9am-4pm} Or how about a period that specifies winter? mo {Nov-Feb} This is equivalent to the previous example: mo {Jan-Feb Nov-Dec} As is mo {jan feb nov dec} And this is too: mo {Jan Feb}, mo {Nov Dec} Wait! So is this: mo {Jan Feb} mo {Nov Dec} To specify a period that describes every other half-hour, use something like minute { 0-29 } To specify the morning, use hour { 12am-11am } Remember, 11am is not 11:00:00am, but rather 11:00:00am - 11:59:59am. Hmmmm, 5 second blocks could be a fun period... sec {0-4 10-14 20-24 30-34 40-44 50-54} To specify every first half-hour on alternating week days, and the second half-hour the rest of the week, use the period wd {1 3 5 7} min {0-29}, wd {2 4 6} min {30-59} VERSION
1.20 HISTORY
Version 1.20 ------------ - Added the ability to specify no time period. Version 1.13 ------------ - Cleaned up the error checking code. Version 1.12 ------------ - Updated email and web space information. Version 1.11 ------------ - Minor bug fix in 1.10. Version 1.10 ------------ - Released. AUTHOR
Patrick Ryan <pgryan@geocities.com> COPYRIGHT
Copyright (c) 1997 Patrick Ryan. All rights reserved. This Perl module uses the conditions given by Perl. This module may only be distributed and or modified under the conditions given by Perl. DATE
August 26, 1997 SOURCE
This distribution can be found at http://www.geocities.com/SiliconValley/Lakes/8456/ or http://www.perl.com/CPAN/modules/by-module/Time/ perl v5.12.1 1997-08-27 Period(3)
All times are GMT -4. The time now is 01:45 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy