LinuxQuestions.org
View the Most Wanted LQ Wiki articles.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices

Reply
 
Search this Thread
Old 09-16-2009, 08:44 AM   #1
bhargavkr
LQ Newbie
 
Registered: Sep 2009
Posts: 1

Rep: Reputation: 0
Create a Multiple files by reading a input file and changing the contents


Being new to this area .I have been assigned a task which i am unable to do . Can any one please help me .

Hi I have requirement where i have input file XYZ_111_999_YYYYMMDD_1.TXT and with header and series of Numbers and Footer.

I want to create a mutiple output files with each file having a seperate code which is stored in text file and create XYZ_222_999_YYYYMMDD_1.TXT . and add date in the contents next to series of numbers .Like this

Before change the file looks like this

file name XYZ_111_999_YYYYMMDD_1.TXT

001,19SEP2009-14:05:05,000000003
1234
4567
6785
END_OF_DATA

Output file should be as below

XYZ_222_111_YYYYMMDD_1.TXT where 222 will be from stored list or text file

001,222,19SEP2009-14:05:05,000000003
1234,19SEP2009-14:05:05,222
4567,19SEP2009-14:05:05,222
6785,19SEP2009-14:05:05,222
END_OF_DATA


List file will be as below

test.txt
222
333
444
555
666
 
Old 09-16-2009, 11:13 AM   #2
TB0ne
Guru
 
Registered: Jul 2003
Location: Birmingham, Alabama
Distribution: SuSE, RedHat, Slack,CentOS
Posts: 14,462

Rep: Reputation: 2538Reputation: 2538Reputation: 2538Reputation: 2538Reputation: 2538Reputation: 2538Reputation: 2538Reputation: 2538Reputation: 2538Reputation: 2538Reputation: 2538
Quote:
Originally Posted by bhargavkr View Post
Being new to this area .I have been assigned a task which i am unable to do . Can any one please help me .

Hi I have requirement where i have input file XYZ_111_999_YYYYMMDD_1.TXT and with header and series of Numbers and Footer.

I want to create a mutiple output files with each file having a seperate code which is stored in text file and create XYZ_222_999_YYYYMMDD_1.TXT . and add date in the contents next to series of numbers .Like this

Before change the file looks like this

file name XYZ_111_999_YYYYMMDD_1.TXT

001,19SEP2009-14:05:05,000000003
1234
4567
6785
END_OF_DATA

Output file should be as below

XYZ_222_111_YYYYMMDD_1.TXT where 222 will be from stored list or text file

001,222,19SEP2009-14:05:05,000000003
1234,19SEP2009-14:05:05,222
4567,19SEP2009-14:05:05,222
6785,19SEP2009-14:05:05,222
END_OF_DATA


List file will be as below

test.txt
222
333
444
555
666
First, your question is confusing. Do you want the results to be like test.txt, or as in XYZ_222_111_YYYYMMDD_1.TXT? They have different outputs, which are you wanting? And what are you writing this program in?

Also, post what you've written, and we can help you with it. But we're not going to write your programs for you.
 
Old 09-16-2009, 07:22 PM   #3
chrism01
Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Centos 6.5, Centos 5.10
Posts: 16,261

Rep: Reputation: 2028Reputation: 2028Reputation: 2028Reputation: 2028Reputation: 2028Reputation: 2028Reputation: 2028Reputation: 2028Reputation: 2028Reputation: 2028Reputation: 2028
@TB0ne: He wants the 2nd format, the test.txt is supplying the new values which are being added in to create the new files. Look at where '222' occurs in the 2nd file.


@OP:I agree, show us what you have done so far and we'll help.

Last edited by chrism01; 09-17-2009 at 12:36 AM.
 
Old 09-16-2009, 09:02 PM   #4
TB0ne
Guru
 
Registered: Jul 2003
Location: Birmingham, Alabama
Distribution: SuSE, RedHat, Slack,CentOS
Posts: 14,462

Rep: Reputation: 2538Reputation: 2538Reputation: 2538Reputation: 2538Reputation: 2538Reputation: 2538Reputation: 2538Reputation: 2538Reputation: 2538Reputation: 2538Reputation: 2538
Quote:
Originally Posted by chrism01 View Post
@TB0ne: He wants the 2nd format, the test.txt is supplying the new values which are being added in to create the new files. Look at where '22' occurs in the 2nd file.


@OP:I agree, show us what you have done so far and we'll help.
That's what I thought, but wasn't sure....
 
Old 09-17-2009, 12:37 AM   #5
chrism01
Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Centos 6.5, Centos 5.10
Posts: 16,261

Rep: Reputation: 2028Reputation: 2028Reputation: 2028Reputation: 2028Reputation: 2028Reputation: 2028Reputation: 2028Reputation: 2028Reputation: 2028Reputation: 2028Reputation: 2028
TBH, that's just my interpretation ...
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
LXer: Reading Multiple Files with Bash LXer Syndicated Linux News 0 08-22-2009 12:00 AM
Create 1 csv file from multiple txt files richmur Programming 10 09-03-2008 01:28 PM
how to create a new file including content from reading another file !? silverhand Programming 2 10-06-2007 04:33 PM
bash: create a descriptor reading/writing from/to different files? Thinking Programming 0 04-19-2006 03:28 PM
Reading Multiple vob files in mplayer finnigan001 Linux - Software 2 10-29-2003 03:59 AM


All times are GMT -5. The time now is 12:19 AM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration