tailieunhanh - Linux erver hacks 2003 phần 8
đưa ra những ưu tiên tài khoản địa phương trong khi vẫn còn sử dụng xác thực miền Windows cho hầu hết các tài khoản. và thủ thuật cho việc tìm kiếm và sử dụng hàng chục các công cụ mã nguồn mở, Nếu không, bạn sẽ cần phải điều hướng thông qua hệ thống tập tin của bạn tự chọn chương trình. | 73 Global Search and Replace with Peri The next switch is a little more complicated it but becomes second nature once you start using it -p. From perldoc perlrun -p causes Perl to assume the following loop around your program which makes it iterate over filename arguments somewhat like sed LINE while . It your program goes here continue print or die -p destination n The line in question _ is automatically printed on every iteration of the loop. If you combine -p and -e you get a one-liner that iterates over every file on the command line or on the text fed to it on STDIN. For example here s a complicated cut command robộcatlin perl -pe 1 etc hosts hosts This file describes a number of hostname-to-address mappings for the TCP IP subsystem. For loopbacking. localhost The 1 is just a return code as if you entered 1 in a Perl script which is equivalent to return 1 . Since the lines are printed automatically we don t really need the program we specify with -e to do anything. Where it gets interesting is in providing a bit of code to manipulate the current line before it gets printed. For example suppose you wanted to append the local machine name to the localhost line rob@catlin perl -pe s localhost localhost ENV HOSTNAME etc hosts hosts This file describes a number of hostname-to-address mappings for the TCP IP subsystem. For loopbacking. localhost or maybe you d like to manipulate your inetd settings rob@caligula perl -pe s A s telnet shell login exec 2 etc That will print the contents of etc to STDOUT commenting out any uncommented telnet shell login or exec lines along the way. Naturally we could redirect that back out to a file but if we just want to edit a file in place there s a better way the -i switch. 152 I Scripting Mincing Your Data into Arbitrary Chunks in bash 74 -i lets you edit files in place. So to comment out all of the above lines in etc you might try root@catlin perl -pi -e s A s
đang nạp các trang xem trước