Sebagai contoh: Di direktori / temp saya, saya punya 100 file .. 50 dengan ekstensi .msg dan 50 dengan .xml.
/temp/test1.xml
/temp/test2.xml
/temp/test3.xml
.........
/temp/test49.xml
/temp/test50.xml
dan
/temp/test1.msg
/temp/test2.msg
/temp/test3.msg
.........
/temp/test49.msg
/temp/test50.msg
Dalam file teks, saya ingin menampilkan kombinasi konten file .xml dan .msg satu demi satu. Misalnya file output akan terlihat seperti:
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
dalam direktori / temp ini akan selalu ada jumlah file .msg dan .xml yang sama. Selain itu, mungkinkah untuk menunjukkan path atau nama file sebelum konten dalam file output? sebagai contoh:
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
Saya telah mencoba pipa sederhana ke file
cat * > text.txt
tetapi ini tidak memberikan hasil yang diperlukan. Dalam file output, pertama-tama daftar konten semua file * .xml kemudian file *.
Tolong bantu.
cat * dapat mendaftar semua file XML sebelum semua file pesan. Dapatkah Anda menguraikan itu? (Juga, milikmu cat perintah tidak memiliki pipa apa pun; hanya menggunakan pengalihan I / O.)