新幼儿园的第二天

早上送去幼儿园的时候仍然要哭闹一下。

下午是她外婆和爷爷去接她,发现一个问题,孩子的教室在三楼,放学时的上楼和下楼的人相当多,很挤。现在好多学校都存在这个问题。像侄女读高中放学也是这样。挤都挤不动。

4.3. Bash Variables Are Untyped, 4.4. Special Variable Types

1、

http://www.linuxsir.org/main/doc/abs/HTML/untyped.html

4.3. Bash Variables Are Untyped

Example 4-4. Integer or string?

  20 c=BB34

  21 echo "c = $c"            # c = BB34

  22 d=${c/BB/23}             # Substitute "23" for "BB".

  23                          # This makes $d an integer.

  24 echo "d = $d"            # d = 2334

2、

http://www.linuxsir.org/main/doc/abs/HTML/othertypesv.html

The space allotted to the environment is limited. Creating too many environmental variables or ones that use up excessive space may cause problems.

 bash$ eval "`seq 10000 | sed -e 's/.*/export var&=ZZZZZZZZZZZZZZ/'`"

 

 bash$ du

 bash: /usr/bin/du: Argument list too long

3、

命令:basename(# Strips out path name info (see 'basename'))

[mdx@localhost abs-exercises]$ basename /home/mdx/abs-guide-3.7/ex15.sh

ex15.sh

4、比较:


16 if [ -n "$1" ]              # Tested variable is quoted.

  17 then

  18  echo "Parameter #1 is $1"  # Need quotes to escape #

  19 fi

5、得到最后一个参数:


   1 args=$#           # Number of args passed.

   2 lastarg=${!args}

   3 # Or:       lastarg=${!#}

   4 #           (Thanks, Chris Monson.)

   5 # Note that lastarg=${!$#} doesn't work.

6、待查

If a script expects a command line parameter but is invoked without one, this may cause a null variable assignment, generally an undesirable result. One way to prevent this is to append an extra character to both sides of the assignment statement using the expected positional parameter.


   1 variable1_=$1_  # Rather than variable1=$1

   2 # This will prevent an error, even if positional parameter is absent.

   3

   4 critical_argument01=$variable1_

   5

   6 # The extra character can be stripped off later, like so.

   7 variable1=${variable1_/_/}

   8 # Side effects only if $variable1_ begins with an underscore.

   9 # This uses one of the parameter substitution templates discussed later.

  10 # (Leaving out the replacement pattern results in a deletion.)

  11

  12 #  A more straightforward way of dealing with this is

  13 #+ to simply test whether expected positional parameters have been passed.

  14 if [ -z $1 ]

  15 then

  16   exit $E_MISSING_POS_PARAM

  17 fi

  18

  19

  20 #  However, as Fabian Kreutz points out,

  21 #+ the above method may have unexpected side-effects.

  22 #  A better method is parameter substitution:

  23 #         ${1:-$DefaultVal}

  24 #  See the "Parameter Substition" section

  25 #+ in the "Variables Revisited" chapter.

7、在Example 4-6. wh, whois domain name lookup中,域名查询的服务器是无效的,可以换成:"wh-inn" ) whois $1@whois.internic.net;;

8、生词:

positional

notch

4.2. Variable Assignment(echo -n,!,$())

1、echo -n的作用简单的说就是不换行,像java中的System.out.print("something");


    19 # In a 'for' loop (really, a type of disguised assignment):

    20 echo -n "Values of \"a\" in the loop are: "

    21 for a in 7 8 9 11

    22 do

    23   echo -n "$a "

    24 done

结果:Values of "a" in the loop are: 7 8 9 11

2、

下面这段的“!”不懂:

  


    10 a=`echo Hello!`   # Assigns result of 'echo' command to 'a'

    11 echo $a

    12 #  Note that including an exclamation mark (!) within a

    13 #+ command substitution construct #+ will not work from the command line,    14 #+ since this triggers the Bash "history mechanism."

    15 #  Inside a script, however, the history functions are disabled.

 

3、``相当于$()


     2 R=$(cat /etc/redhat-release)

4、英语生词:

disguised

naked

trailing

4.1. Variable Substitution(双引号,一行赋多值,未初始化变量)�

1、双引号内的变量可以保留变量值当中的超过一个空格的空格:

(abs-guide-3.7/HTML/variables.html#VARSUBN)

Example 4-1. Variable assignment and substitution


  33 hello="A B  C   D"

  34 echo $hello   # A B C D

  35 echo "$hello" # A B  C   D

  36 # As you see, echo $hello   and   echo "$hello"   give different results.

  37 #                                      ^      ^

  38 # Quoting a variable preserves whitespace.

2、可以在一行中对多个变量赋值,但是在有可能引起版本兼容性问题:

(abs-guide-3.7/HTML/variables.html#VARSUBN)

Example 4-1. Variable assignment and substitution


  57 #  It is permissible to set multiple variables on the same line,

  58 #+ if separated by white space.

  59 #  Caution, this may reduce legibility, and may not be portable.

  60

  61 var1=21  var2=22  var3=$V3

  62 echo

  63 echo "var1=$var1   var2=$var2   var3=$var3"

  64

  65 # May cause problems with older versions of "sh".

3、在没有初始化的变量上进行算术运算不是非法的,当作是"0",但是在有可能引起版本兼容性问题:

(abs-guide-3.7/HTML/variables.html#VARSUBN)


An uninitialized variable has a "null" value - no assigned value at all (not zero!). Using a variable before assigning a value to it will usually cause problems.

It is nevertheless possible to perform arithmetic operations on an uninitialized variable.

   1 echo "$uninitialized"                                # (blank line)

   2 let "uninitialized += 5"                             # Add 5 to it.

   3 echo "$uninitialized"                                # 5

   4

   5 #  Conclusion:

   6 #  An uninitialized variable has no value, however

   7 #+ it acts as if it were 0 in an arithmetic operation.

   8 #  This is undocumented (and probably non-portable) behavior.

我的redhat linux9.0的/etc/fstab


LABEL=/                 /                       ext3    defaults        1 1

/dev/hdc5              /boot                   ext2    defaults        1 2

none                    /dev/pts                devpts  gid=5,mode=620  0 0

none                    /proc                   proc    defaults        0 0

none                    /dev/shm                tmpfs   defaults        0 0

/dev/hdc7              /usr/local              ext3    defaults        1 2

/dev/hdc9               swap                    swap    defaults        0 0

/dev/hdc12              /home                   ext3    defaults        1 2

/dev/fd0                /mnt/floppy             auto    noauto,owner,kudzu 0 0

/dev/cdrom              /mnt/cdrom              udf,iso9660 noauto,owner,kudzu,ro 0 0

我因为分区的时候有几个分区没有指定LABEL,所以只能以设备名来装载。这样,当把硬盘从主盘换到从盘,或者从IDE0换到IDE1时,设备名就变了,这样就必须修改这个文件才能正常使用。

也不知道怎么样在已使用分区上添加LABEL?

新学年新幼儿园的第一天

今年把孩子送到离家较远的一个较大的幼儿园了。学费要贵一些,但是看来条件要好点。

早上是她的妈妈和外婆送她去的,大人刚走的时候要哭闹一下,等会儿悄悄去看时,老师把她安排在第一排,正在听老师讲呢。

临近中午,她妈妈去告诉她,让她中午就在那里吃饭,大人下午放学去接她。她脸色不高兴,但是还是没有哭闹。

下午是她爷爷和我去接她的(她爷爷提前没说去接她,所以我也去了)。

老师说她很乖。问她,她也说老师喜欢她,幼儿园很好玩。

中午她还破天荒的睡了午觉,这2个月在家里从来没有睡过午觉。

孩子回来后情绪还不错,只是吃起饭来很急,估计是中午在幼儿园没吃饱。教她中午没吃饱就向老师说。

新学年的开头一天情况不错。

Ctl-M(Carriage return.)(不懂)

read echo >$2 不懂

(http://www.linuxsir.org/main/doc/abs/HTML/special-chars.html)

Ctl-M

Carriage return.

   1 #!/bin/bash

   2 # Thank you, Lee Maschmeyer, for this example.

   3

   4 read -n 1 -s -p $'Control-M leaves cursor at beginning of this line. Press Enter. \x0d'

   5                                   # Of course, '0d' is the hex equivalent of Control-M.

   6 echo >&2   #  The '-s' makes anything typed silent,

   7            #+ so it is necessary to go to new line explicitly.

   8

   9 read -n 1 -s -p $'Control-J leaves cursor on next line. \x0a'

  10            #  '0a' is the hex equivalent of Control-J, linefeed.

  11 echo >&2

  12

  13 ###

  14

  15 read -n 1 -s -p $'And Control-K\x0bgoes straight down.'

  16 echo >&2   #  Control-K is vertical tab.

  17

  18 # A better example of the effect of a vertical tab is:

  19

  20 var=$'\x0aThis is the bottom line\x0bThis is the top line\x0a'

  21 echo "$var"

  22 #  This works the same way as the above example. However:

  23 echo "$var" | col

  24 #  This causes the right end of the line to be higher than the left end.

  25 #  It also explains why we started and ended with a line feed --

  26 #+ to avoid a garbled screen.

  27

  28 # As Lee Maschmeyer explains:

  29 # --------------------------

  30 #  In the [first vertical tab example] . . . the vertical tab

  31 #+ makes the printing go straight down without a carriage return.

  32 #  This is true only on devices, such as the Linux console,

  33 #+ that can't go "backward."

  34 #  The real purpose of VT is to go straight UP, not down.

  35 #  It can be used to print superscripts on a printer.

  36 #  The col utility can be used to emulate the proper behavior of VT.

  37

  38 exit 0

 

http://files.rarlab.com/rar/rarlinux-3.2.0.tar.gz

今天,在网上下载了一个rar文件,发现redhat linux9.0系统没有这个解压软件,上网下载了一个3.6版本的,结果执行报告没有libstdc++.so.6,经查,是GCC和c++库的版本太低了的原因,只是libstdc++.so.5,下载一个完整的又要好像30~40M,太大了。于是,在网上搜了一下2003年左右发行的rar,标题就是下载的地址,记下来备用。

Linux下交换文件的创建与使用(转帖)

(转自:布落格的烘培机)

布??格的烘培??

有一种鸟儿是永远也关不住的,因为它的每片羽翼上都沾满了自由的光辉

导航

 · 主页

 · 管理

 · TagCloud

 · RainbowSoft Studio

 · GoogleLogoShow

 · Z-Blog论坛

 · Z-Blog主页

 · 搜索

<< [Flickr]1元硬币微拍重新制做的两个附加功能插件 >>

2005-12-8 9:47:29

Linux下交换文件的创建与使用

Linux的交换文件相当于Windows的虚拟内存,不过Linux可以使用整个分区做为交换空间,

也可以像Windows一样使用单个的文件做虚拟内存。

  Linux支持虚拟内存, 就是使用磁盘作为RAM的扩展,使可用内存相应地有效扩大。核

心把当前不用的内存块存到硬盘,腾出内存给其他目的。当原来的内容又要使用时,再读

回内存。这对用户全透明:运行于Linux的程序只看到大量的可用内存而不甘心哪部分在磁

盘上。当然,读写硬盘比真的内存慢(慢千倍),所以程序运行较慢。用做虚拟内存的这部

分硬盘叫 对换空间。

在单机环境下感觉使用单个文件要比划一整个分区好用,而且比较灵活。

下面就用mkswap在根目录下建立一个128M的交换文件:

1.先创建一个128M的空文件

dd if=/dev/zero of=/swapfile bs=1024 count=131072

2.标识该文件为交换文件

mkswap ?c /swapfile 131072

3.启用交换文件

sync

swapon /swapfile

4.写入fstab中,自动激活

例如:

/dev/hda8 none swap sw 0 0

/swapfile none swap sw 0 0

关闭交换空间可以用swapoff命令

Tags: Linux  系统  使用 

发布:rainbowsoft | 分类:Linux生活 | 评论:0 | 引用:0 | 浏览:

 · 点击这里获取该日志的TrackBack引用地址

 · 相关文章:

 · Cedega在Ubuntu6.06下的一个怪问题和运行WOW的问题  (2006-8-13 17:01:14)

    USB读卡器制作启动盘的补充及其它  (2006-1-17 6:33:30)

    USB读卡器加存储卡制作系统引导盘  (2006-1-14 20:37:37)

    网站调整待定备案仍需努力  (2005-12-29 1:43:12)

    对不起,我回来啦  (2005-12-28 1:29:04)

    试试Flock下的XML-RPC发布  (2005-12-17 19:48:22)

    使用Zoundry发布你的Z-Blog  (2005-11-14 18:36:41)

    收到寄来的Ubuntu光盘  (2005-10-29 20:30:04)

    T-Mobile SDA(欧版多普达575)使用小记及其它  (2005-10-17 18:01:56)

    Linux使用记之五(Ubuntu安装设置全集)  (2005-9-12 18:11:22)

发表评论:

[                            ] 名称(*)

[                            ] 邮箱

[                            ] 网站链接

[                            ] 验证(*) [c_validc]

正文(*)(留言最长字数:1000)

[                                                  ]

[                                                  ]

[                                                  ]

[                                                  ]

[提交] [ ] 记住我,下次回复时不用重新输入个人信息

?欢迎参与讨论,请在这里发表您的看法、交流您的观点。

日历

最新留言

最近发表

Powered By Z-Blog 1.6 Final Build 60816

Copyright 1999-2005 RainbowSoft Studio. Some Rights Reserved.