Rằng âm thanh như sấm là gì? Oh, nó chỉ là những người sử dụng sed chạy tán loạn về phía phòng ăn nhẹ để tải về miễn phí cookie trong khi họ vẫn có thể. Thận trọng trong số họ làm như vậy, bởi vì hầu hết các phiên bản của sed có lịch sử không có một điều khoản để tiết kiệm đầu ra của nó trong các tập tin ban đầu! Kết quả là, một số I / O thêm tranh cãi là cần thiết, mà thường được kịch bản có nghĩa là dò dẫm với một biên tập viên, loại bỏ. | URGENT NEW CORPORATE DECREE ON TERMINOLOGY CDT Headquarters HQ has just informed us that as of today all company documents must henceforth use the word trousers instead of the newly politically incorrect pants. All IT employees should immediately make this Document Conversion Operation DCO their top priority TP . The Office of Corporate Decree Enforcement OCDE will be scanning all computer files for compliance starting tomorrow and for each document that s found to be in violation the responsible parties will be forced to forfeit their Free Cookie Privileges FCPs for one day. So please comply with HQ s CDT on the TP DCO ASAP before the OCDE snarfs your FCPs. What s that thundering sound Oh it s just the sed users stampeding toward the snack room to load up on free cookies while they still can. It s prudent of them to do so because most versions of sed have historically lacked a provision for saving its output in the original file In consequence some extra I O wrangling is required which should generally be scripted which means fumbling with an editor removing the inevitable bugs from the script accidentally introducing new bugs and so forth. Meanwhile back at your workstation you as a Perl aficionado can Lazily compose a test-case using the file in which you have wisely been accumulating pant-related phrases in preparation for this day cat pantaloony WORLDWIDE PANTS SPONGEBOB SQUAREPANTS Now for the semi-magical Perl incantation that s made to order for this pants-to-trousers upgrade perl -wpl -e s bPANTS b TROUSERS ig pantaloony cat pantaloony WORLDWIDE TROUSERS SPONGEBOB SQUAREPANTS It worked. Your Free Cookie Privileges might be safe after all Why did the changes appear in the file rather than only on the screen Because the i invocation option which enables in-place editing causes each input file in this case pantaloony to become the destination for its own filtered output. That means it s critical when you use the n option not to forget to print or else