Linux Shell±Ê¼Ç £¨Ò»£©
1¡¢±äÁ¿ºÍÔËËã (×¢£º´ÓÉÏÍùÏÂÒ»²½Ò»²½Ö´ÐÐ)
1.±¾µØ±äÁ¿ÔÚÓû§ÏÖÔÚµÄshellÉúÃüÆڵĽű¾ÖÐʹÓÃ
variable-name=value ÀýÈ磺test="test"
2.setÏÔʾ±¾µØËùÓеıäÁ¿
3.Éè³ÉÖ»¶Á±äÁ¿£ºreadonly variable-name ÀýÈ磺test="cynric" »á³ö´í
readonlyÃüÁî¿ÉÒԲ鿴ËùÓеÄÖ»¶Á±äÁ¿
4.±äÁ¿Ìæ»»
${Variable name} ÏÔʾʵ¼ÊÖµµ½variable name
${Variable name:+value} Èç¹ûÉèÖÃÁËvariable name,ÔòÏÔʾvalue£¬·ñÔòΪ¿Õ
ÀýÈ磺echo ${test:+"abcd"} ÏÔʾabcd
echo ${cywosp:+"abcd"} ÏÔʾΪ¿Õ
${Variable name:?value} Èç¹ûδÉèÖÃvariable name,ÏÔʾÓû§¶¨ÒåµÄ´íÎóÐÅÏ¢value
ÀýÈ磺echo ${cywosp:?"no defined"} ÏÔʾno defined
echo ${test:?"no defined"} ÏÔʾtest
${Variable name:-value} Èç¹ûδÉèÖÃvariable name,ÔòÏÔʾÆäÖµvalue
ÀýÈ磺echo ${cywosp:-"no defined"} ÏÔʾno defined
echo ${test:-"no defined"} ÏÔʾtest
${Variable name:=value} Èç¹ûδÉèÖÃVarible name,Ôò½«ÆäÖµ¸³Îªvalue²¢ÏÔʾ
ÀýÈ磺echo ${cywosp:="cywosp"} ÏÔʾcywosp
echo ${test:="test"} ÏÔʾtest
5¡¢±äÁ¿µÄÇå³ý
unset variable-name ÀýÈ磺unset cywosp
×¢£ºreadonlyµÄ±äÁ¿²»ÄÜunset£¬ËùÒÔreadonlyÒª½÷É
Ïà¹ØÎĵµ£º
//»ñÈ¡±¾»úIPµØÖ·º¯Êý
QString GetLocalIp()
{
int sock_get_ip;
char ipaddr[50];
struct sockaddr_in *sin;
struct ifreq ifr_ip;
if ((sock_get_ip=socket(AF_INET, SOCK_STREAM, 0)) == -1)
{
printf("socket create failse...GetLocalIp!\n");
return ""; ......
1¡¢int 4×Ö½Ú
long 8×Ö½Ú
float 4×Ö½Ú
double 8×Ö½Ú
long double 16×Ö½Ú
2¡¢Ò»¸ö×Ö·û±äÁ¿Ö»ÄÜ´æ·ÅÒ»¸ö×Ö·û¡¢Ò»¸ö×Ö½Ú´æ·ÅÒ»¸ö×Ö½Ú
char c;
c = 'a'; c = '\034' ......
add linux kernel min, max define:
include/linux/kernel.h
/*
* min()/max() macros that also do
* strict type-checking.. See the
* "unnecessary" pointer comparison.
*/
#define min(x,y) \
(__extension__\
({ \
typeof( ......
²»³£Óõ«·Ç³£ÊµÓõÄÃüÁî
UNIXÃüÁîÊDzâÊԱر¸µÄ֪ʶ£¬³ýÁËһЩ³£ÓõÄÃüÁîÐèÒªÊìϤÒÔÍ⣬Óкܶà·Ç³£ÓÐÓõ«ÊDz»³£ÓõÄÃüÁîÒ²ÐèÒªÁ˽⣬ÕâÑù¶Ô¹¤×÷ÓкܴóµÄ°ïÖú£¬ÕâÀïÌṩһЩÎÒƽ³£¹¤×÷ÖÐÀÛ»ýµÄ֪ʶ£¬Ï£ÍûÄÜ°ïÖúµ½´ó¼Ò ^_^
1¡¢Í³¼ÆËùÓÐÎļþÖеļǼÊý£ºwc -l filename
2¡¢²é¿´¹²ÏíÄڴ棺ipcs -m
3¡¢viÖеÄÅúÁ¿×Ö·ûÆ¥Å䣨a- ......