Ò׽ؽØÍ¼Èí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö160KB

LinuxÖØ¶¨ÏòÏê½â

×ªÔØ£ºhttp://www.cnblogs.com/hexapodsoft/archive/2007/04/24/724902.html
I/OÖØ¶¨ÏòÏê½â¼°Ó¦ÓÃʵÀý
1¡¢ »ù±¾¸ÅÄÕâÊÇÀí½âºóÃæµÄ֪ʶµÄǰÌᣬÇëÎñ±ØÀí½â£©
a¡¢ I/OÖØ¶¨Ïòͨ³£Óë FDÓйأ¬shellµÄFDͨ³£Îª10¸ö£¬¼´ 0¡«9£»
b¡¢ ³£ÓÃFDÓÐ3¸ö£¬Îª0£¨stdin£¬±ê×¼ÊäÈ룩¡¢1£¨stdout£¬±ê×¼Êä³ö£©¡¢2£¨stderr£¬±ê×¼´íÎóÊä³ö£©£¬Ä¬ÈÏÓëkeyboard¡¢monitor¡¢monitorÓйأ»
c¡¢ Óà < À´¸Ä±ä¶Á½øµÄÊý¾ÝÐŵÀ(stdin)£¬Ê¹Ö®´ÓÖ¸¶¨µÄµµ°¸¶Á½ø£»
d¡¢ Óà > À´¸Ä±äËͳöµÄÊý¾ÝÐŵÀ(stdout, stderr)£¬Ê¹Ö®Êä³öµ½Ö¸¶¨µÄµµ°¸£»
e¡¢ 0 ÊÇ < µÄĬÈÏÖµ£¬Òò´Ë < Óë 0<ÊÇÒ»ÑùµÄ£»Í¬Àí£¬> Óë 1> ÊÇÒ»ÑùµÄ£»
f¡¢ ÔÚIOÖØ¶¨Ïò ÖУ¬stdout Óë stderr µÄ¹ÜµÀ»áÏÈ×¼±¸ºÃ£¬²Å»á´Ó stdin ¶Á½ø×ÊÁÏ£»
g¡¢ ¹ÜµÀ“|”(pipe line):ÉÏÒ»¸öÃüÁîµÄ stdout ½Óµ½ÏÂÒ»¸öÃüÁîµÄ stdin;
h¡¢ tee ÃüÁîÊÇÔÚ²»Ó°ÏìÔ­±¾ I/O µÄÇé¿öÏ£¬½« stdout ¸´ÖÆÒ»·Ýµ½µµ°¸È¥;
i¡¢ bash£¨ksh£©Ö´ÐÐÃüÁîµÄ¹ý³Ì£º·ÖÎöÃüÁ±äÁ¿ÇóÖµ£­ÃüÁîÌæ´ú£¨``ºÍ$( )£©£­Öض¨Ïò£­Í¨Åä·ûÕ¹¿ª£­È·¶¨Â·¾¶£­Ö´ÐÐÃüÁ
j¡¢
( ) ½« command group ÖÃÓÚ sub-shell È¥Ö´ÐУ¬Ò²³Æ nested
sub-shell£¬ËüÓÐÒ»µã·Ç³£ÖØÒªµÄÌØÐÔÊÇ£º¼Ì³Ð¸¸shellµÄStandard input, output, and error plus
any other open file descriptors¡£
k¡¢ exec ÃüÁ³£ÓÃÀ´Ìæ´úµ±Ç° shell ²¢ÖØÐÂÆô¶¯Ò»¸ö shell£¬»»¾ä»°Ëµ£¬²¢Ã»ÓÐÆô¶¯×Ó shell¡£Ê¹ÓÃÕâÒ»ÃüÁîʱÈκÎÏÖÓл·¾³¶¼½«»á±»Çå³ý¡£exec ÔÚ¶ÔÎļþÃèÊö·û½øÐвÙ×÷µÄʱºò£¬Ò²Ö»ÓÐÔÚÕâʱ£¬exec ²»»á¸²¸ÇÄ㵱ǰµÄ shell »·¾³¡£
2¡¢ »ù±¾IO
cmd > file °Ñ stdout ÖØ¶¨Ïòµ½ file ÎļþÖУ»
cmd >> file °Ñ stdout ÖØ¶¨Ïòµ½ file ÎļþÖÐ(×·¼Ó)£»
cmd 1> fiel °Ñ stdout ÖØ¶¨Ïòµ½ file ÎļþÖУ»
cmd > file 2>&1 °Ñ stdout ºÍ stderr Ò»ÆðÖØ¶¨Ïòµ½ file ÎļþÖУ»
cmd 2> file °Ñ stderr ÖØ¶¨Ïòµ½ file ÎļþÖУ»
cmd 2>> file °Ñ stderr ÖØ¶¨Ïòµ½ file ÎļþÖÐ(×·¼Ó)£»
cmd >> file 2>&1 °Ñ stderr ºÍ stderr Ò»ÆðÖØ¶¨Ïòµ½ file ÎļþÖÐ(×·¼Ó)£»
cmd < file >file2 cmd ÃüÁîÒÔ file Îļþ×÷Ϊ stdin£¬ÒÔ file2 Îļþ×÷Ϊ stdout£»
cat <>file ÒÔ¶ÁдµÄ·½Ê½´ò¿ª file£»
cmd < file cmd ÃüÁîÒÔ file Îļþ×÷Ϊ stdin£»
cmd << delimiter Here document£¬´Ó stdin ÖжÁÈ룬ֱÖÁ


Ïà¹ØÎĵµ£º

Linux erron³£Á¿

#define EPERM            1      /* Operation not permitted */
#define ENOENT           2      /* No such file or directory */
#define ESRCH&nbs ......

Unix/Linux»·¾³³£Óÿâ¼ò½é

Ò»¸ö³ÌÐòµÄ¿ª·¢Àë²»¿ªÐí¶à¿âº¯ÊýµÄÖ§³Ö£¬¿ÉÊÇ¿âÈç´ËÖ®¶à£¬ÓпªÔ´Ãâ·ÑµÄÒ²ÓÐÊշѵġ£ºÜÏ£ÍûÊìϤ±à³ÌµÄǰ±²°Ñ×Ô¼ºµÄ¾­ÑéÕûÀíÏ£¬³£ÓõĿⶼ°üº¬ÄÄЩ¹¦ÄÜ¡£ÏÂÎÄÊÇÔÚÍøÉÏÕÒµÄÒ»¸öÀàËÆµÄ×ÊÁÏ¡£ÆÚ´ý¸ü¶à¸üÈ«µÄÄÚÈÝ¡£
---------------------------------------------------------------------------------------------------
¿´µ ......

linux 0.11 ÄÚºËѧϰ char_dev.c


/*
 *  linux/fs/char_dev.c
 *
 *  (C) 1991  Linus Torvalds
 */
#include <errno.h>
#include <sys/types.h> // ¶¨ÒåÁË»ù±¾µÄϵͳÊý¾ÝÀàÐÍ
#include <linux/sched.h>
#include <linux/kernel.h> // º¬ÓÐһЩÄں˳£Óú¯ÊýµÄÔ­Ðζ¨Òå
#include < ......

linux 0.11 ÄÚºËѧϰ buffer.c


/*
 * buffer.c ³ÌÐòÓÃÓÚ¶Ô¸ßËÙ»º³åÇø(³Ø)½øÐвÙ×÷ºÍ¹ÜÀí¡£¸ßËÙ»º³å
 * ÇøÎ»ÓÚÄں˴úÂëºÍÖ÷ÄÚ´æÇøÖ®¼ä¡£
 *
 *  |---|---|------------------|---------------------|-------------------|
 *  |   |   |    *   *    *    | &nbs ......

linuxÉèÖà ÈÃoracle10g×ÔÆô¶¯


ÔÚ/etc/rc.d/init.d/ ´´½¨oracle10gÎļþ
touch oracle10g
chmod a+x oracle10g
[root@test~]# vi /etc/rc.d/init.d/oracle10g
#!/bin/bash
#chkconfig:345 51 49
#description:starts the oracle database deamons
#
ORACLE_HOME=/oracle/product/10.2.0/db_1
ORACLE_OWNER=oracle
case "$1" in
start)
echo ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØÍ¼ | ¸ÓICP±¸09004571ºÅ