ubuntu, ror, jQuery, css, website memo
太嫩, 沒啥心得, 用來紀錄每天學的
2009年4月18日 星期六
apache cache 常用的static file
Apache Web Server Cache Frequently Used Files To Improve Performance
Linux / Unix Command: sed
Does Linux Have a Search & Replace Feature?
#找到 /var/www/domain.com/kb 底下全部的 file 不包含目錄, 在前面加上 mmapfile 的字串, 把這些弄成 /etc/httpd/conf.d 的file<br /># 那個 & 可以代表match 的部份<br />find /var/www/domain.com/kb/ -type f -print | sed -e 's/.*/mmapfile &/' > /etc/httpd/conf.d/mmap.conf<br />
cat filename | sed -n '/1024/p'<br /><br />#Here, sed filters the output from the cat command. The option "-n" tells sed to block all the incoming lines but those explicitly matching the expression. The sed action on a match is "p"= print.<br />
cat filename | sed '/.*o$/d' > new_file<br /><br />In this EXAMPLE, lines ending with an "o" will be deleted. It uses a regular expression for matching any string followed by an "o" and the end of the line. The output (i.e., all lines but those ending with "o") is directed to new_file.<br />
#To search and replace, use the sed 's' action, which comes in front of two expressions:<br /><br /> cat filename | sed 's/string_old/string_new/' > newfile<br /><br />#A shorter form for the last command is:<br /><br /> sed 's/string_old/string_new/' filename > newfile<br /><br />#To insert text from a text file (text_added.txt) into an html file, you may use a script containing:<br /><br /> sed '/placeholder_text_in_html_file/r text_added.txt'<br /> index_master_file.html > index.html<br /><br />
<br />#EX:delete blank lines and redirect the output<br />$sed '/^$/d' file > file.out<br /><br />#Ex: takes input from who command and check whether particular user is logged or not<br />$who | sed -n '/nix/p'<br />
沒有留言:
張貼留言
較新的文章
較舊的文章
首頁
訂閱:
張貼留言 (Atom)
沒有留言:
張貼留言