linux С¼¼ÇÉ
linux С¼¼ÇÉ
Ç°ÑÔ£ºÒòΪÓÃLinuxµÄʱ¼äÔ½À´Ô½³¤£¬ËùÐèÒª×öµÄÊÂÒ²Ô½À´Ô½¶à£¬Ð§ÂʳÉÁËÎÒ±ØÐèÍ»ÆƵÄÆ¿¾±¡£ÔÚ´Ë×ܽáÒ»ÏÂÕâ¶Îʱ¼äÓùýµÄһЩºÃµÄLinux¼¼ÇÉ¡£ÒÔºóʱ³£²¹³äÕâÑù×Ô¼ºÒªÓõÄʱºò¾ÍºÜ·½±ãÁË¡£ Author:Ajian[Îı¾´¦Àí]1¡¢ ...
Ç°ÑÔ£ºÒòΪÓÃLinuxµÄʱ¼äÔ½À´Ô½³¤£¬ËùÐèÒª×öµÄÊÂÒ²Ô½À´Ô½¶à£¬Ð§ÂʳÉÁËÎÒ±ØÐèÍ»ÆƵÄÆ¿¾±¡£ÔÚ´Ë×ܽáÒ»ÏÂÕâ¶Îʱ¼äÓùýµÄһЩºÃµÄLinux¼¼ÇÉ¡£ÒÔºóʱ³£²¹³äÕâÑù×Ô¼ºÒªÓõÄʱºò¾ÍºÜ·½±ãÁË¡£
Author:Ajian
[Îı¾´¦Àí]
1¡¢²é¿´Ä³ÎļþµÄÒ»²¿·Ö
Èç¹ûÄãÖ»Ïë¿´ÎļþµÄÇ° 5 ÐУ¬¿ÉÒÔʹÓà head ÃüÁ
È磺head -5 /etc/passwd
Èç¹ûÄãÏë²é¿´ÎļþµÄºó 10 ÐУ¬¿ÉÒÔʹÓà tail ÃüÁ
È磺tail -10 /etc/passwd
²é¿´ÎļþÖмäÒ»¶Î£¬¿ÉÒÔʹÓà sed ÃüÁî
Èç:sed –n '5,10p' /etc/passwd ÕâÑùÄã¾Í¿ÉÒÔÖ»²é¿´ÎļþµÄµÚ 5 Ðе½µÚ 10 ÐÐ
2¡¢½« file.txt ÀïµÄ123¸ÄΪ 456
·½·¨ 1
sed 's/123/456/g' file.txt > file.txt.new Ð޸ĵı£´æµ½ÆäËüÎļþ
sed -i 's/123/456/g' file.txt Ö±½ÓÐÞ¸ÄÔÎļþ
·½·¨ 2
vi file.txt
ÊäÈëÃüÁ
:%s/123/456/g
×¢Ò⣺Èç¹ûÌæ»»µÄÎļþÓÐÌØÊâ·ûºÅÈç/¾ÍÒªÓÃ\À´È¡Ïû¡£
Àý£ºsed -i 's/\/usr\/local\/apache2\/htdocs/\/var\/www\/html/g' /usr/local/apache2/conf/httpd.conf
Èç¹ûÖ»ÊÇÏÂÔÓеÄÐкóÌí¼Ó¾ÍÓÃ&
Àý£ºsed -i 's/DirectoryIndex index.html index.html.var/& index.htm index.php /g' /usr/local/apache2/conf/httpd.conf
3¡¢echo µäÐÍÓ¦ÓÃ
echo "abcdefg" | perl -lne '{$a = reverse($_); print $a;}' °ÑÒ»¸ö×Ö·û´®·×ª
echo bottle|rev °ÑÒ»¸ö×Ö·û´®·×ª
[ÎļþĿ¼¹ÜÀí]
1¡¢É¾³ý¼¸ÌìÒÔÇ°µÄËùÓж«Î÷(°üÀ¨Ä¿Â¼ÃûºÍĿ¼ÖеÄÎļþ£©
1) find . -ctime +3 -exec rm -rf {} \;
2) find ./ -mtime +3 -print|xargs rm -f –r
2¡¢Ôڶ༶Ŀ¼ÖвéÕÒij¸öÎļþµÄ·½·¨
1) find /dir -name filename.ext
2) du -a | grep filename.ext
3) locate filename.ext
3¡¢É¾³ýÈíÓ²Á¬½Ó×¢Òâµã
ɾ³ýÈí¼þÁ¬½ÓµÄʱºòÒ»¶¨Òª¼ÇµÃ²»ÒªÔÚɾ³ýµÄÎļþ¼Ðºó¼Óһб¸Ü,
rm -f filename/
»á˵ÕâÊÇÒ»¸öÎļþ¼Ð²»ÄÜɾ³ý
rm filename
»áÌáʾ˵ÊÇ·ñҪɾ³ýÕâ¸öÁ¬½Ó¡£
Èç¹ûÓõĵÚÒ»ÖÖ¿ÉÄÜ»á°ÑÆäËüÎļþ¶¼É¾³ý
4¡¢É¾³ýĿ¼Öк¬ÊäÈë¹Ø¼ü×ÖµÄÎļþ
find /mnt/ebook/ -type f -exec grep "ÔÚ´ËÊäÈë¹Ø¼ü×Ö" {} \; -print -exec
Ïà¹ØÎĵµ£º
ÕâÊǽ»Linux±¨¸æµÄÂÛÎÄ:
²¿·Ö×ÊÁÏÊÇ´ÓIBMÌṩ¸øÎÒÃÇѧԺµÄ×ÊÁÏÉÏ·ÒëµÄ.
Ö÷ÒªÊǹØÓÚLinuxÎļþϵͳµÄ,Ï£Íû¶Ô´ó¼ÒÁ˽âLinuxϵͳÓÐËù°ïÖú.
LinuxµÄ¸ùÎļþϵͳϸ÷¸öĿ¼µÄ×÷ÓÃ:
ÔÚLinuxÖÐÎļþϵͳ¹¹½¨ºÍUNIXÖв¶à£¬µ«Á½Õß»¹ÊÇÓÐһЩСµÄ³öÈë¡£
ÏÂͼÊÇLinuxÖÐÎļþϵͳ½á¹¹µÄ ......
rsync ÓÐʲôͻ³öÓŵãÄØ£¿Ê×ÏÈ£¬Ëü±»Éè¼Æ³ÉÖ»´«ËÍÎļþµÄ²»Í¬²¿·Ö£¬¶ø·Ç´«ËÍÕû¸öÎļþ£¬ÒÔ¼ÓËÙÎļþ´«Êä¡£±ÈÈ磬ÎÒÕýÔÚд×÷±¾ÎÄ£¬ÄÇÎҾͿÉÒÔÏÖÔÚʹÓÃ
rsync ¸´ÖÆÒ»´Î£¬¶øÖ®ºóÔÙ½øÐÐÒ»´Î´«Êä¡£µÚ¶þ´Î£¨µÚÈý´Î¡¢µÚËÄ´Î……£©¸¸×ÓÎļþµÄʱºò£¬rsync
Ö»´«ËÍÎļþµÄ²»Í¬²¿·Ö¡£Õ⽫¼«´óµØ½Úʡʱ¼ä£¬ÌرðÊÇÔÚÈÕ³£±¸·ÝµÄ¹ ......
linuxÄں˻ù±¾Êý¾ÝÀàÐÍ×ܽá
¶ÔlinuxÄں˵ÄÊý¾ÝÀàÐÍ×öÒ»ÏÂ×ܽᡣ
ÏÂÃ沿·ÖÄÚÈݲο¼ÁË£ºhttp://book.csdn.net/bookfiles/12/100126.shtml
µ±
Linux
ÄÚºËÔÚÌåϵ½á¹¹²îÒì½Ï´óµÄƽ̨֮¼äÒÆֲʱ£¬»á²úÉúÓëÊý¾ÝÀàÐÍÏà¹ØµÄÎÊÌâ¡£ÔÚ±àÒëÄÚºËʱʹÓÃ
-Wall -Wstrict-prototypes
Ñ¡Ï¿ÉÒÔ±ÜÃâºÜ¶à´íÎóµÄ·¢Éú¡£
ÄÚºËʹÓõĻ ......
·½·¨Ò»¡¢
bool ReadElemnt(string& szFileName)
{
TiXmlDocument myDocument(szFileName);
bool loadOkay = myDocument.LoadFile();
if(loadOkay == false)
return false;
TiXmlElement *rootElement = myDocument.RootElement();
if(rootEle ......