DumbTerminal Posted October 12, 2005 Report Share Posted October 12, 2005 (edited) Hi guysI was wondering if it is possible to copy the contents of several files into a new file?I have 3 files conf1.txt, conf2.txt, conf3.txtI want to put the contents of all 3 files into one file; masterconf.txtIs this possible? If so, can someone give me the syntax?I tried a few different cp commands, but without the desired results.I haven't seen this covered in Google, only copying multiple files into one directory, etc..Thanks!Edit:I've found batch files from Googling, but that's not exactly what I am looking for, and my feeble mind doesn't understand them. Edited October 12, 2005 by DumbTerminal Quote Link to post Share on other sites
shanenin Posted October 12, 2005 Report Share Posted October 12, 2005 (edited) I am not sure I am following. Do you want to put them in something like a zip file? in linux there is the tar file.the idea would be to make a directory, and call it for example: conf_files, then move all of your .txt files to the directory called conf_files.now to tar up the files into one file do the following commandtar -cf conf_files.tar conf_filesedit added later//if you just want to make one long text file. you could do thiscat {conf1.txt,conf2.txt,conf3.txt} >> newfile.txt Edited October 12, 2005 by shanenin Quote Link to post Share on other sites
DumbTerminal Posted October 12, 2005 Author Report Share Posted October 12, 2005 I am not sure I am following. Do you want to put them in something like a zip file? in linux there is the tar file.the idea would be to make a directory, and call it for example: conf_files, then move all of your .txt files to the directory called conf_files.now to tar up the files into one file do the following commandtar -cf conf_files.tar conf_files<{POST_SNAPBACK}>No, I wanted to copy all of the information in the 3 seperate configuration files into one single configuration file.I just copied the info from the 3 files individually and pasted it into one file.I was just thinking it would be cool if there were a quicker, easier way to do that.Thanks for responding Quote Link to post Share on other sites
shanenin Posted October 12, 2005 Report Share Posted October 12, 2005 I ammended my first post, with what you wnated to do Quote Link to post Share on other sites
DumbTerminal Posted October 12, 2005 Author Report Share Posted October 12, 2005 I ammended my first post, with what you wnated to do<{POST_SNAPBACK}> Sweet, thanks very muchI thought I had a bookmark on how to do that, but I couldn't find it.I forgot about using cat to write out contents...I learn so much (sometimes TOO much) about CLI everyday.I have several conf files I want to experiment with, and this will probably save me literally hours!Thanks again. Quote Link to post Share on other sites
shanenin Posted October 12, 2005 Report Share Posted October 12, 2005 you could also have done it manually, one file at a timecat conf1.txt > new_file.txtcat conf2.txt >> new_file.txtcat conf3.txt >> new_file.txtusing one '>' will cause the info for cat conf1.txt to erase and start a new file. using two '>>' will cause the file to be ammened to the end. Quote Link to post Share on other sites
jcl Posted October 13, 2005 Report Share Posted October 13, 2005 cat {conf1.txt,conf2.txt,conf3.txt} >> newfile.txt<{POST_SNAPBACK}>FWIW the brace expansion isn't necessary. Quote Link to post Share on other sites
shanenin Posted October 13, 2005 Report Share Posted October 13, 2005 (edited) good point, the braces just complicate it. Edited October 13, 2005 by shanenin Quote Link to post Share on other sites
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.