ShellÓï·¨catÏÂÁî¿ÉÒÔÓÃÀ´ºÏ²¢²î±ðĿ¼Ï¶à¸öÎı¾Îļþ
ÃÕµ×£ºcat ÏÂÁî¿É½«²î±ðĿ¼ÏµÄÎı¾ÎļþºÏ²¢µ½Ò»¸öÐÂÎļþÖС£Ó÷¨£ºÓï·¨£ºcat [Ñ¡Ïî] Îļþ1 Îļþ2 … ÎļþnÑ¡Ï-n£º¶ÔºÏ²¢ºóµÄÎļþÄÚÈݾÙÐÐÐкűê×¢-e£ºÔÚÿһÐеÄĩβ¸½¼Ó»»Ðзû-s£ººöÂÔÒ»Á¬µÄ¿ÕÐÐ-u£º½«ºÏ²¢ºóµÄÎļþÄÚÈÝÏÔʾÔÚ믧³åģʽÏÂʾÀý£ºcat /home/user/documents/file1.txt /home/user/downloads/file2.txt /home/user/projects/file3.txt > merged.txt
Shell Óï·¨ÖÐ cat ÏÂÁîºÏ²¢²î±ðĿ¼ÏµÄÎı¾Îļþ
cat ÏÂÁîÊÇ Linux ºÍ Unix ϵͳÖг£ÓõÄÏÂÁÓÃÓÚÔÚÖÕ¶ËÖÐÆ´½ÓºÍÏÔʾÎı¾ÎļþµÄÄÚÈÝ¡£Ëü»¹¾ßÓкϲ¢¶à¸öÎı¾ÎļþµÄ¹¦Ð§£¬ÕâÔÚÐèÒª½«ÊèÉ¢ÔÚ²î±ðĿ¼ÏµÄÎļþÄÚÈÝ»ã×ÜʱºÜÊÇÓÐÓá£
Óï·¨£º
cat [Ñ¡Ïî] Îļþ1 Îļþ2 ... Îļþn
µÇ¼ºó¸´ÖÆ
Ñ¡Ï
- -n£º¶ÔºÏ²¢ºóµÄÎļþÄÚÈݾÙÐÐÐкűê×¢
- -E£ºÔÚÿһÐеÄĩβ¸½¼ÓÒ»¸ö»»Ðзû£¬×ÝÈ»¸ÃÐÐ×îºó´¦Ã»Óл»Ðзû
- -s£ººöÂÔÒ»Á¬µÄ¿ÕÐÐ
- -u£º½«ºÏ²¢ºóµÄÎļþÄÚÈÝÏÔʾÔÚ믧³åģʽÏ£¬ÒÔ¾ÙÐÐʵʱ¸üÐÂ
Ó÷¨Ê¾Àý£º
¼ÙÉèÎÒÃÇÓÐÈý¸öÎı¾Îļþ£ºfile1.txt¡¢file2.txt ºÍ file3.txt£¬»®·ÖλÓÚ²î±ðµÄĿ¼ÖУº
- file1.txt£º/home/user/Documents/file1.txt
- file2.txt£º/home/user/Downloads/file2.txt
- file3.txt£º/home/user/Projects/file3.txt
ÎÒÃÇ¿ÉÒÔʹÓÃÒÔÏÂÏÂÁÕâÈý¸öÎı¾ÎļþºÏ²¢µ½Ò»¸öÐÂÎļþÖУ¬ÃûΪ merged.txt£º
cat /home/user/Documents/file1.txt /home/user/Downloads/file2.txt /home/user/Projects/file3.txt > merged.txt
µÇ¼ºó¸´ÖÆ
Ч¹û£º
merged.txt Îļþ½«°üÀ¨ file1.txt¡¢file2.txt ºÍ file3.txt µÄÄÚÈÝ£¬°´ÉÏÊö˳ÐòÅÅÁС£
×¢ÖØ£º
- cat ÏÂÁî»áÁýÕÖÏÖÓÐÎļþ¡£ÈôÊÇ merged.txt Òѱ£´æ£¬ÆäÄÚÈݽ«±»ºÏ²¢Îı¾ÎļþµÄÄÚÈÝÌæ»»¡£
- ÈôÊÇÒª½«ºÏ²¢ºóµÄÎļþÄÚÈݸ½¼Óµ½ÏÖÓÐÎļþ£¬ÇëʹÓà >> È¡´ú >¡£
ÒÔÉϾÍÊÇShellÓï·¨catÏÂÁî¿ÉÒÔÓÃÀ´ºÏ²¢²î±ðĿ¼Ï¶à¸öÎı¾ÎļþµÄÏêϸÄÚÈÝ£¬¸ü¶àÇë¹Ø×¢±¾ÍøÄÚÆäËüÏà¹ØÎÄÕ£¡