For example: In my /temp directory I have 100 files.. 50 with the extension of .msg and 50 with .xml.
/temp/test1.xml
/temp/test2.xml
/temp/test3.xml
.........
/temp/test49.xml
/temp/test50.xml
and
/temp/test1.msg
/temp/test2.msg
/temp/test3.msg
.........
/temp/test49.msg
/temp/test50.msg
In a text file, I would like to output a combination of the contents of the .xml and .msg files one after the other. For example the output file should look like:
content of test1.xml
content of test1.msg
content of test2.xml
content of test2.msg
content of test3.xml
content of test3.msg
............
content of test49.xml
content of test49.msg
content of test50.xml
content of test50.msg
in this /temp directory there will always be an equal number of .msg and .xml files. Additionally will it be possible to show the path or the file name before the content in the output file? for example:
text1.xml: content of test1.xml
text1.msg: content of test1.msg
text2.xml: content of test2.xml
text2.msg: content of test2.msg
text3.xml: content of test3.xml
text3.msg: content of test3.msg
....................
text49.xml: content of test49.xml
text49.msg: content of test49.msg
text50.xml: content of test50.xml
text50.msg: content of test50.msg
I have tried a simple pipe to file
cat * > text.txt
but this does not give required result. In the output file, it first lists the content of all the *.xml files then the *.msg files.
Please assist.
cat *
could list all the XML files before all the message files. Can you elaborate on that? (Also, yourcat
command has no pipes whatsoever; it only uses I/O redirection.)