Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Printing data to a file

Status
Not open for further replies.

patraf

Programmer
Sep 28, 2001
5
IE
Hi there, I'm currently writing a script to take in inform store into a file and compare with another file. So at the moment the task its performing is searching through a file for certain inform. once found it prints to the outputb screen. So instead printing 2 the screen, I want it to print to a file, which I want it then to be compared to another file, these results are then stored into another separate file, could anyone help?
Thanks Patrick
 
Patrick,

About your print to file, this is how to do it

open(FILE,">file.txt");
print FILE "This is the text to send to file\n";
close(FILE);

About the compare: this is more tricky and I cann't give you a strait answer. The only tip I would give you, if you want to work with line comparaisons is to work with hashes (if you are looking for uniqueness).

Thierry

AD AUGUSTA PER ANGUSTA

Thierry
 
Thierry,
Thanks for your help its much appreciated, one last thing! I have another script 2 write. It envolves sending a list of directories to a file, which I have done, I then need to read in each directory individually and then set up maybe a loop to read down through the list and open each individual directory. Any suggestions would be greatly received,
Thanks Patrick.
 
Patrick, check out the "opendir" and "readdir" commands. When using those commands, I always try to use absolute file names - it saves a lot of headaches rather than trying to use relative paths.

HTH.
Hardy Merrill
Mission Critical Linux, Inc.
 
Anyone know C programming?
I am writting code in C to compare 2 files and output the differences, I have done this part but I need help in writting a function to translate the data.
For example if the difference between the two files is a heading called waff123, this does not make much sense so I want to write a function that when ever it has a particular heading it will output a heading that makes sense eg Waffer size. Also there may be up to 1000 headings and I have a list of all the headings and what they mean but how do I write a section of code that will allow me do do this.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top