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 wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Merging/Combining multiple text files that are in same dir

Status
Not open for further replies.
Feb 20, 2004
5
US
I need a little script that will take all the text files in a directory and make one. I would like to first create the target file and then append all the other files in the directory to it.


For those who wish the details.
I know this is has too many steps.
I am using BGInfo from sysinternals on all (or trying to get it on all) our Windows servers. It queries the server for information you have config'd (Hostname, IPs, GWs, DNSs, Role, Domain, Disk space, Mem, CPU, even custom queries, etc....) and can put it up as a background wallpaper. Really nifty when using KVM and want to insure you are on the right box and want some quick info. (BTW it is free). Anyways....it can also output that info to a CSV file. I have found a CSV to XML converter (free as well). So I have figured up to this point. I am going to create a batch file that runs the BGInfo to create fresh info into a csv file, then run the XML converter on it, and then FTP it to a specific directory that matches the servers role on my Linux server. All the XML files will be the same format and have the same info. Now I want to append all those files into one big one that is created with the necessary header. I will have a style sheet for it and then I will have a neat little web page I can look at to get info on all my servers.

Any help on this would be appreciated.
If there is already a How-To on this that I am unaware of....point me in the direction please.
Thanks
 
If all your text files are sequentially named e.g. file001.txt file002.txt file003.txt ... file[nnn].txt etc. You can just do a simple:

cat file*.txt > result.txt

This is true on my RH9 box. Do not know if this differs on other distros.

--== Anything can go wrong. It's just a matter of how far wrong it will go till people think its right. ==--
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top