החלטתי לפתוח מדור טיפים לשורת הפקודה של לינוקס (ולא רק).
המטרה: לתת במה למספר פקודות פשוטות ויעילות שלא בהכרח מוכרות לכולם.
הערה: ההסברים לקוחים מהפאלם האישי ולכן כתובים באנגלית
tee
redirections are great tools for sending command output (stdout) to a file (other than the screen). pipe make the output of one command as input of other command
But if you want, in a single command, to do two things:
display the command output on the screen and write it to a file. In this case you should use the tee command
Examples:
ls | tee ls.txt
ls | tee -a ls.txt
the -a option will append the file (default is overwrite)
These commands will display the contents of the current directory on the screen, and write the same information to ls.txt file
מומלץ להפנות את פלט השגיאות לפלט הרגיל לפני tee וזאת כדי שכל המידע יכתב לקובץ. אחרת המידע על השגיאות הולך לאיבוד, ובסקריפטים הוא בד"כ חשוב.
חוץ מזה, זה אחלה כלי.
קיבלתי. כלומר לבצע:
ls 2>stdout |tee ls.txt