Text file creation problem


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Text file creation problem
# 1  
Old 01-20-2012
Text file creation problem

Using KSH, I have one text file which just contains a list of distinct references on each line, e.g.;

123456789
987654321
15457544X
164450200

etc. The file will always be called "InputRefs.txt".

The number of distinct refs will be different each time.

For each line (distinct ref) I want to create a new text file. The file name should be the same as the reference, followed by .txt. and the contents of the text file should be a standard message which is the same in each file, e.g. "This is a standard message, same in each file. Thank you".

Additionally, I need to create a new 'control file' which is basically a CSV text file with a record for each of the records in the first file, with some additional standardised fields.

E.g. in the above example, the control file's first row would be;

"123456789.doc","123456789","DOCTYPE",20/01/2012 00:00:00,"B"

Fields 1 and 2 refer to the ref in the first file. Fields 3 - 5 are the same for each other row in the file, but the date must be the run date.

The name of the control file should be "ControlFile_20120120_17_01_20).csv" (with the date being the run date, and the last values the time - 17:01:20).

Can anyone assist?

I thought about using a grep in a for loop, but how would I print the standard message in each .txc file? Also really unsure about getting the date in the control contents and the date+time onto the control file's name.

Thank you.
# 2  
Old 01-20-2012
In ksh I would use a read loop:
Code:
while read reference
do
  echo "your operations with variable $reference go here"
done < InputRefs.txt

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Programming

File creation problem

I am creating a file to store data, but the file does not get created at all. #include <unistd.h> #define DEFAULT_ID 0 int main() { int d, n=0; int sz, data=0; char fn; char *bv; snprintf(fn, 256, "bv", DEFAULT_ID); bv=fn; printf("%s\n", bv); if ((d =... (4 Replies)
Discussion started by: powyama
4 Replies

2. Programming

problem with xsd file creation

Hi every one, I am new to xml data files,I have two xml files with same data but only small difference as shown below <List> <number>1101</number> <Area>inner walls in a room.</Area> <Detection>less pressure.</Detection> <reason> <normal> <Component Num="15"... (1 Reply)
Discussion started by: veerubiji
1 Replies

3. Shell Programming and Scripting

Help with creating a text file in perl with file creation date.

Hi, I am quite new to Perl scripting and i need to create a .TXT file using perl, with fields (A,B,C,D,E), and this text file should be named with current file creation date "XYZ_CCYYMMDD.TXT" (i.e.XYZ_2011042514:33 PM). Can anyone who has done this, please share their expertise on this... (5 Replies)
Discussion started by: msrahman
5 Replies

4. AIX

User creation problem

Hi, I am getting tired in creating several users in a day. Can anyone have a script to create several users in the same server, as well as, to create one user in several servers. where i have to put script and how to run the script. Waiting for your reply. Thanks in advance (5 Replies)
Discussion started by: udtyuvaraj
5 Replies

5. Shell Programming and Scripting

File Creation Problem

I recently got a problem with a program. It said that Create a file using shell script and insert details in it and take a String from the user and see whether it matches with any of the details of the String. I know how to create a file, insert details, but hw to check whether the String matches... (2 Replies)
Discussion started by: ramj
2 Replies

6. HP-UX

Problem With exceutable file creation

Hello , I came up with a new problem during creation of an exceutable file. My application all the c files and links them to create a new executable file. Till last month everything was fine and yester day i tried to change one file and tried to create an exe file but unsuccesfull. I am... (8 Replies)
Discussion started by: jagan_kalluri
8 Replies

7. Solaris

File creation problem

Hi to all, I am facing a strange problem on the Solaris-10 server. I am unable to create/write files on the server. After writing, when I go for the save, then it gives me and 'jag: I/O error'..where 'jag' is a file name. Please suggest me... Regards, Jagdish Machhi (2 Replies)
Discussion started by: jagdish.machhi@
2 Replies

8. Shell Programming and Scripting

problem with link creation!!!!

I have a home directory namely /pto/ppa/ridbmw/etl/ Now i have various directorys below the home directory. For eg from the home directory if i say cd /roddata it changes to that directory. I think its kind of link (I don't know if it's hard or soft). Now i need to create a new directory and... (4 Replies)
Discussion started by: dsravan
4 Replies

9. UNIX for Dummies Questions & Answers

user creation problem

hello, Actually I want to create a user for our brower based custom application for the mail access from our mailserver(linux). I create user dummy and I granted all the privileages to dummy user and made dummy equivelent to root and if I tried to create a another user logging as dummy ... (1 Reply)
Discussion started by: jarkvarma
1 Replies

10. UNIX for Dummies Questions & Answers

Text based user creation

:confused: How do you create new users on solaris 2.5 (5.7) without being on the console? with AIX I used SMIT - is there a text based user creation tool? Can't find one.... (5 Replies)
Discussion started by: n9ninchd
5 Replies
Login or Register to Ask a Question