解决Redhat linux9.0下jdk1.4.2_01-b06的中文问题

这几天准备对学习日记作点小的改动(房子虽然太简单,也需要修整修整呀),把停了一个来月的学习日记开发环境在linux下搭起来了。当我运行java软件ArgoUML建模,发现不能在软件中输入汉字,保存对话框的“是”与“否”的中文字体为方框。我知道碰到了传说中的linux下java的中文乱码问题。

于是,请出google老师,他帮我找到了一篇帖子,于是,受文中的启发,在下面目录对文件font.properties.zh_CN.Redhat8.0作了一个符号链接font.properties.zh.Redhat,中文乱码问题就没有了。如下:


ln -s /usr/jdk1.4/jre/lib/font.properties.zh_CN.Redhat8.0 /usr/jdk1.4/jre/lib/font.properties.zh.Redhat

很简单吧,但是我不知道具体原因是什么。也许font.properties.zh.Redhat是Redhat系统在java中的默认字体设置文件?哪为什么在这个目录下又有这么多的字体设置文件,如下:


[root@localhost lib]# dir font.*

font.properties                 font.properties.ja.Sun           font.properties.zh_CN.Sun

font.properties.ja              font.properties.ja.Turbo         font.properties.zh_CN_UTF8.Sun

font.properties.ja_JP_UTF8.Sun  font.properties.ja.Turbo6.0      font.properties.zh.Redhat

font.properties.ja.Redhat6.1    font.properties.ko.Redhat8.0     font.properties.zh.Turbo

font.properties.ja.Redhat6.2    font.properties.Redhat6.1        font.properties.zh_TW.Redhat8.0

font.properties.ja.Redhat7.2    font.properties.Redhat8.0        font.properties.zh_TW.Sun

font.properties.ja.Redhat7.3    font.properties.SuSE8.0          font.properties.zh_TW_UTF8.Sun

font.properties.ja.Redhat8.0    font.properties.zh_CN.Redhat8.0

[root@localhost lib]#

***********************************************************************************

附上那篇介绍有Redhat linux9.0下java中文设置的文章,实际上是一篇讲Redhat linux9.0下oracle安装的文章,也许以后用得着,收藏在这里参考:

转自:http://www.xxlinux.com/linux/article/development/database/20060905/3956.html

RedHat9.0操作的oracle9i安装

[ 作者:Linux联盟收集  加入时间:2006-09-05 21:52:36  来自:Linux联盟收集 ]

作者:pxe2

先安装修改java

标准 jre/jdk 中只带了 redhat 6 的 font.properties, 需要建一个 font.properties.zh.Redhat 放在 redhat 的 jre/lib 目录下。打开 /usr/lib/X11/fonts/ttf-zh 或者 /usr/share/fonts/zh_CN/TrueType 下面的 font.dir, 将其中的一个中文字体名复制下来,比如 -misc-ZYSong18030-medium-r-normal--0-0-0-0-c-0-iso10646-1,按照 java 的字体规则改为 -misc-ZYSong18030-medium-r-normal--*-%d-*-*-c-*-iso10646-1,将 font.properties.zh 中的内容复制到 font.properties.zh.Redhat 中。

我选用字体 -misc-ZYSong18030-medium-r-normal--0-0-0-0-c-0-iso10646-1 是因为在 redhat 7.3 和 redhat 8.0 上都能用。

因为 jre/jdk 找不到 Redhat 的 true type 字体,在文件 font.properties.zh.Redhat 最后加入

appendedfontpath=/usr/lib/X11/fonts/ttf-zh

appendedfontpath=/usr/share/fonts/zh_CN/TrueType

将字体名全部替换成 -misc-ZYSong18030-medium-r-normal--*-%d-*-*-c-*-iso10646-1,替换后的 font.properties.zh.Redhat 如下:

# @(#)font.properties.zh.Redhat.linux 1.4 02/06/10

#

# Copyright 2002 Sun Microsystems, Inc. All rights reserved.

#

# Component Font Mappings

#

serif.0=-misc-ZYSong18030-medium-r-normal--*-%d-*-*-c-*-iso10646-1

serif.italic.0=-misc-ZYSong18030-medium-r-normal--*-%d-*-*-c-*-iso10646-1

serif.bold.0=-misc-ZYSong18030-medium-r-normal--*-%d-*-*-c-*-iso10646-1

serif.bolditalic.0=-misc-ZYSong18030-medium-r-normal--*-%d-*-*-c-*-iso10646-1

sansserif.0=-misc-ZYSong18030-medium-r-normal--*-%d-*-*-c-*-iso10646-1

sansserif.italic.0=-misc-ZYSong18030-medium-r-normal--*-%d-*-*-c-*-iso10646-1

sansserif.bold.0=-misc-ZYSong18030-medium-r-normal--*-%d-*-*-c-*-iso10646-1

sansserif.bolditalic.0=-misc-ZYSong18030-medium-r-normal--*-%d-*-*-c-*-iso10646-1

monospaced.0=-misc-ZYSong18030-medium-r-normal--*-%d-*-*-c-*-iso10646-1

monospaced.italic.0=-misc-ZYSong18030-medium-r-normal--*-%d-*-*-c-*-iso10646-1

monospaced.bold.0=-misc-ZYSong18030-medium-r-normal--*-%d-*-*-c-*-iso10646-1

monospaced.bolditalic.0=-misc-ZYSong18030-medium-r-normal--*-%d-*-*-c-*-iso10646-1

dialog.0=-misc-ZYSong18030-medium-r-normal--*-%d-*-*-c-*-iso10646-1

dialog.italic.0=-misc-ZYSong18030-medium-r-normal--*-%d-*-*-c-*-iso10646-1

dialog.bold.0=-misc-ZYSong18030-medium-r-normal--*-%d-*-*-c-*-iso10646-1

dialog.bolditalic.0=-misc-ZYSong18030-medium-r-normal--*-%d-*-*-c-*-iso10646-1

dialoginput.0=-misc-ZYSong18030-medium-r-normal--*-%d-*-*-c-*-iso10646-1

dialoginput.italic.0=-misc-ZYSong18030-medium-r-normal--*-%d-*-*-c-*-iso10646-1

dialoginput.bold.0=-misc-ZYSong18030-medium-r-normal--*-%d-*-*-c-*-iso10646-1

dialoginput.bolditalic.0=-misc-ZYSong18030-medium-r-normal--*-%d-*-*-c-*-iso10646-1

# Missing Glyph Character

#

default.char=274f

# Component Font Character Encodings

#

fontcharset.serif.0=sun.io.CharToByteISO8859_1

fontcharset.serif.1=sun.awt.motif.CharToByteX11GBK

fontcharset.sansserif.0=sun.io.CharToByteISO8859_1

fontcharset.sansserif.1=sun.awt.motif.CharToByteX11GBK

fontcharset.monospaced.0=sun.io.CharToByteISO8859_1

fontcharset.monospaced.1=sun.awt.motif.CharToByteX11GBK

fontcharset.dialog.0=sun.io.CharToByteISO8859_1

fontcharset.dialog.1=sun.awt.motif.CharToByteX11GBK

fontcharset.dialoginput.0=sun.io.CharToByteISO8859_1

fontcharset.dialoginput.1=sun.awt.motif.CharToByteX11GBK

# Exclusion Ranges

#

# XFontSet Information

#

fontset.serif.plain=

-misc-ZYSong18030-medium-r-normal--*-%d-*-*-c-*-iso10646-1

fontset.serif.italic=

-misc-ZYSong18030-medium-r-normal--*-%d-*-*-c-*-iso10646-1

fontset.serif.bold=

-misc-ZYSong18030-medium-r-normal--*-%d-*-*-c-*-iso10646-1

fontset.serif.bolditalic=

-misc-ZYSong18030-medium-r-normal--*-%d-*-*-c-*-iso10646-1

fontset.sansserif.plain=

-misc-ZYSong18030-medium-r-normal--*-%d-*-*-c-*-iso10646-1

fontset.sansserif.italic=

-misc-ZYSong18030-medium-r-normal--*-%d-*-*-c-*-iso10646-1

fontset.sansserif.bold=

-misc-ZYSong18030-medium-r-normal--*-%d-*-*-c-*-iso10646-1

fontset.sansserif.bolditalic=

-misc-ZYSong18030-medium-r-normal--*-%d-*-*-c-*-iso10646-1

fontset.monospaced.plain=

-misc-ZYSong18030-medium-r-normal--*-%d-*-*-c-*-iso10646-1

fontset.monospaced.italic=

-misc-ZYSong18030-medium-r-normal--*-%d-*-*-c-*-iso10646-1

fontset.monospaced.bold=

-misc-ZYSong18030-medium-r-normal--*-%d-*-*-c-*-iso10646-1

fontset.monospaced.bolditalic=

-misc-ZYSong18030-medium-r-normal--*-%d-*-*-c-*-iso10646-1

fontset.dialog.italic=

-misc-ZYSong18030-medium-r-normal--*-%d-*-*-c-*-iso10646-1

fontset.dialog.bold=

-misc-ZYSong18030-medium-r-normal--*-%d-*-*-c-*-iso10646-1

fontset.dialog.bolditalic=

-misc-ZYSong18030-medium-r-normal--*-%d-*-*-c-*-iso10646-1

fontset.dialog.plain=

-misc-ZYSong18030-medium-r-normal--*-%d-*-*-c-*-iso10646-1

fontset.dialoginput.italic=

-misc-ZYSong18030-medium-r-normal--*-%d-*-*-c-*-iso10646-1

fontset.dialoginput.bold=

-misc-ZYSong18030-medium-r-normal--*-%d-*-*-c-*-iso10646-1

fontset.dialoginput.bolditalic=

-misc-ZYSong18030-medium-r-normal--*-%d-*-*-c-*-iso10646-1

fontset.dialoginput.plain=

-misc-ZYSong18030-medium-r-normal--*-%d-*-*-c-*-iso10646-1

#fontset.default=

#-b&h-lucida-medium-r-normal-sans-*-%d-*-*-p-*-iso10646-1,

#-tlc-song-medium-r-normal--*-%d-*-*-c-*-gbk-0

fontset.default=

-misc-ZYSong18030-medium-r-normal--*-%d-*-*-c-*-iso10646-1

appendedfontpath=/usr/lib/X11/fonts/ttf-zh

appendedfontpath=/usr/share/fonts/zh_CN/TrueType

使用 Installanywhere 我们编译安装程序选择 "其它 java 平台" 编译成一个 java 的 setup.jar 文件,

在 Redhat 上面写一个批处理/脚本文件, set classpath , 包含 setup.jar,

批处理/脚本文件中使用 java install 启动安装程序。

繁体中文依法炮制即可,建立 font.properties.zh_TW.Redhat 文件,将其中的字体名改为一个繁体中文字体名,

在文件末尾加上合适的 appendedfontpath

___________________________________________________________

1安装好RedHat9.0操作系统,确保安装了以下的RPM开发包

gcc

cpp

glibc-devel

compat-libstdc++

glibc-kernheaders

binutils

可以使用命令来查看是否已安装了这些包

rpm -q gcc cpp compat-libstdc++ glibc-devel glibc-kernheaders binutils

2从Oracle官方网站下载Oracle9i安装文件并使用如下命令解包

zcat lnx_920_disk1.cpio.gz | cpio -idmv

zcat lnx_920_disk2.cpio.gz | cpio -idmv

zcat lnx_920_disk3.cpio.gz | cpio -idmv

(注意磁盘空间)

然后会有Disk1 Disk2 Disk3三个子目录。

3设置内核参数

echo 4294967295 > /proc/sys/kernel/shmmax,建议放到/etc/rc.local文件里。



编辑/etc/sysctl.conf

kernel.shmmax=4294967295

我有512MB内存,所以设置这个数值。可根据实际情况设置。

4创建Oracle用户帐号和安装目录

在shell下,作为root

groupadd dba

groupadd oinstall

useradd -g oinstall -G dba oracle

passwd oracle

mkdir /opt/oracle

mkdir /opt/oracle/product

mkdir /opt/oracle/product/9.2.0

chown -R oracle.oinstall /opt/oracle

mkdir /var/oracle

chown oracle.dba /var/opt/oracle

chmod 755 /var/opt/oracle

5设置环境变量

编辑/home/oracle/.bash_profile文件,添加下列行

export LD_ASSUME_KERNEL=2.4.1

export ORACLE_BASE=/opt/oracle

export ORACLE_HOME=/opt/oracle/product/9.2.0

export ORACLE_SID=ora9i

export ORACLE_TERM=xterm

$ORACLE_HOME/network/admin

export NLS_LANG=AMERICAN_AMERICAN.ZHS16GBK

export ORA_NLS33=$ORACLE_HOME/ocommon/nls/asmin/data

LD_LIBRARY_PATH=$ORACLE_HOME/lib:/lib:/usr/lib

LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/lib

export LD_LIBRARY_PATH

export PATH=$PATH:$ORACLE_HOME/bin

CLASSPATH=$ORACLE_HOME/JRE:$ORACLE_HOME/jlib:$ORACLE_HOME/rdbms/jlib

CLASSPATH=$CLASSPATH:$ORACLE_HOME/network/jlib

export CLASSPATH

6安装

进入Disk1目录

./runInstaller

当link进行到61%时出现一个关于ins_oemagent错误,选择ignore,安装完后修复

当link进行到84%时出现一个关于ins_ctx错误,编辑$ORACLE_HOME/ctx/lib/env_ctx.mk文件,把$(LDLIBFLAG)dl加到以下位置

INSO_LINK=-L$(CTXLIB)$ (LDLIBFLAG)m $(LDLIBFLAG)dl处。

安装完成

修复第一个错误

在shell下,oracle用户

cd $ORACLE_HOME/network/lib

make -f ins_client.mk install

编辑$ORACLE_HOME/ctx/lib/ins_ctx文件

13-14行处

$(LINK) $(CTXHXOBJ) $(INSO_LINK)



$(LINK) -ldl $(CTXHXOBJ) $(INSO_LINK)

7启动数据库、监听程序、web server。

启动数据库

Sqlplus " / as sysdba"

SQL>startup

启动监听程序

lsnrctl

启动web server

cd $ORACLE_HOME/Apache/Apache/bin

./startJServ.sh'

来源:linuxfans

还有问题请来论坛寻求帮助:http://www.xxlinux.com/bbs/

winrar多卷压缩方法

我是在windows xp sp2上使用WINRAR 3.50 beta 5进行分卷压缩的。

但是,在一个文件夹上单击右键添加到rar文件是不行的。

采用以下步骤完成分卷压缩:

1、打开winrar软件:

2、点击左上角的“添加”按纽:

3、在“压缩分卷大小”中选择或输入每卷要压缩的大小,点击“确定”即可:

在大硬盘上安装系统记

今天在一个80G上的硬盘重新分区并用ghost镜像光盘安装windows xp sp2。碰到两个问题,记在这里交流。一个问题是:DOS自带的分区程序fdisk不能识别大硬盘;二是安装系统后用pqmagic8.0中文版无法成功一次执行完所有的分区任务;

过程如下:

1、首先在DOS状态下用fdisk删除所有原分区;

2、在DOS下用fdisk创建分区时发现fdisk不能正确的识别这个80G的硬盘,只认成了9个多G的硬盘,创建主DOS分区是把认出的“9个多G”的空间全部划给它。重启后格式化C盘用了20分钟左右,格式化完成后,系统识别出了C盘的容量为约74个G。也就是一个分区把全部硬盘的容量占完了;

3、用ghost镜像光盘安装完windows xp sp2,是ntfs格式;

4、下载pqmagic8.0中文版,安装在windows xp sp2上(pqmagic8.0中文版可以支持ntfs格式),用pqmagic8.0定好分区系列任务后,选择应用,系统重启,执行pqmagic任务失败,进入系统后仍然只有一个分区;

5、用pqmagic8.0制定一个分区任务后,即选择应用执行,(如:第一个分区任务是调整C盘的分区容量),重启系统后再用pqmagic制定执行另一个任务,终于按计划完成分区。

6、用ghost镜像备份系统盘。完成。

PS:如果有DOS下的支持大硬盘的分区程序在执行安装前完成分区,速度就可以快点,如果你碰巧手边没有这种分区软件,恐怕也只有这样了。

错误678:远程计算机没反应。

我是铁通上网,这段时间(尤其是晚上)常常不能adsl拨号连接,问了铁通的服务人员,说是我的网卡可能不稳定,还问我adsl上的LINK灯是不是亮着的,如果是亮着的,就是他们把信号送到了用户,问题在用户这方面。我对这方面的知识是一点都没有,也就不能提出什么不同的意见来。不过,(也许是巧合),有几次网络联不上发生在我在计算机上用usb接口给手机充电后。也许跟手机充电有关?但又觉得可能性不大,以前就是这样给手机充电的都没有事。又查了一下网上的论坛,在铁通的本地门户的论坛上也有朋友提出类似的问题,有的回答是adsl的model有毛病,有的说网络有问题。还是没有确切的答案。问题的屏幕截图如下:

1、

2、

3、

9.2. Manipulating Strings

9.2. Manipulating Strings

1、String Length

expr "$string" : '.*'

3、Index这个表达式跟java的用法好像不同

expr index $string $substring

    Numerical position in $string of first character in $substring that matches.


   5 echo `expr index "$stringZ" 1c`              # 3

   6 # 'c' (in #3 position) matches before '1'.

4?{string:position:length}负数参数的用法有点怪

    Extracts $length characters of substring from $string at $position.


  16 echo ${stringZ:-4}                           # abcABC123ABCabc

  17 # Defaults to full string, as in ${parameter:-default}.

  18 # However . . .

  19

  20 echo ${stringZ:(-4)}                         # Cabc

  21 echo ${stringZ: -4}                          # Cabc

  22 # Now, it works.

  23 # Parentheses or added space "escape" the position parameter.

  24

  25 # Thank you, Dan Jacobson, for pointing this out.

而且下面这段不懂:


    If the $string parameter is "*" or "@", then this extracts a maximum of

$length positional parameters, starting at $position.

       1 echo ${*:2}          # Echoes second and following positional

parameters.

       2 echo ${@:2}          # Same as above.

       3

       4 echo ${*:2:3}        # Echoes three positional parameters, starting

at second.

5、Example 9-12. Emulating getopt其中的字符串处理不甚明了


  14       if [ ${1:0:1} = '/' ]

  15       then

  16           tmp=${1:1}               # Strip off leading '/' . . .

  17           parameter=${tmp%%=*}     # Extract name.

  18           value=${tmp##*=}         # Extract value.

  19           echo "Parameter: '$parameter', value: '$value'"

  20           eval $parameter=$value

  21       fi

6、awk处理函数不懂


  14 # The awk equivalent of ${string:pos:length} is

substr(string,pos,length).

  15 echo | awk '

  16 { print substr("'"${String}"'",3,4)      # skid

  17 }

  18 '

7、9.2.2. Further Discussion进一步讨论的几个例子没看

英语疑问:

1、emulation, getopt

A simple emulation of getopt  using substring extraction constructs.

用局域网中的电脑作网关共享上网

因为不能在局域网的集线器上直接连入互联网,我于是用了一根双机互连的网线、和在局域网中的一台机子上加了一块网卡来解决了新加入机子的上网问题。

网关电脑是windows xp sp2,客户机是redhat linux9.0。

先是采用sysgate安在windows xp上,不成功。因为原来我做个网关电脑用adsl上网的双机互连共享上网,用windows xp上的共享连接不行,用sysgate才成功了。所以这次我首先就试了用sysgate共享上网。

然后,不改变两台机子互连的网卡的IP设置,在windows xp上用系统自带的internet连接共享来做。结果成功。

这两种情况成功和失败的原因都没有找到,记在这里可以作为一个小的经验吧。

9.1. Internal Variables

9.1. Internal Variables

1、不懂:


$DIRSTACK

    the top value in the directory stack (affected by pushd and popd)

    This builtin variable corresponds to the dirs command, however dirs shows

    the entire contents of the directory stack.

2、

 


$EUID

    "effective" user ID number

    Identification number of whatever identity the current user has assumed,

    perhaps by means of su.

    Caution The $EUID is not necessarily the same as the $UID.

3、


  $GLOBIGNORE

    A list of filename patterns to be excluded from matching in globbing.

4、


     root# echo ${GROUPS[1]}

     1

5、


    $IFS defaults to whitespace (space, tab, and newline), but may be changed,

    for example, to parse a comma-separated data file. Note that $* uses the

    first character held in $IFS. See Example 5-1.

     bash$ echo $IFS | cat -vte

     $

     bash$ bash -c 'set w x y z; IFS=":-;"; echo "$*"'

     w:x:y:z

6、IFS是空格时,字符间的多个空格视为一个分隔符,第一个字符前面的空格会忽略不计。见例子ifs.sh。


              14 IFS=" "

              15 var=" a  b c   "

 ...

              26 IFS=:

              27 var=":a::b:c:::"               # Same as above, but substitute

运行结果:


[mdx@localhost abs-exercises]$ ./ex9-1.sh

IFS=" "

-------

the arg is: [a]

the arg is: [b]

the arg is: [c]

IFS=:

-----

the arg is: []

the arg is: [a]

the arg is: []

the arg is: [b]

the arg is: [c]

the arg is: []

the arg is: []

[mdx@localhost abs-exercises]$

7、$LINENO 不懂


$LINENO

    This variable is the line number of the shell script in which this

variable

    appears. It has significance only within the script in which it appears,

    and is chiefly useful for debugging purposes.

       1 # *** BEGIN DEBUG BLOCK ***

       2 last_cmd_arg=$_  # Save it.

       3

       4 echo "At line number $LINENO, variable \"v1\" = $v1"

       5 echo "Last command argument processed = $last_cmd_arg"

       6 # *** END DEBUG BLOCK ***

8、$PIPESTATUS不懂,并且在本机上的执行结果与书中的不同


     bash$ echo $PIPESTATUS

     0

     bash$ ls -al | bogus_command

     bash: bogus_command: command not found

     bash$ echo $PIPESTATUS

     141

     bash$ ls -al | bogus_command

     bash: bogus_command: command not found

     bash$ echo $?

     127

...

          bash$ echo ${PIPESTATUS[@]}

9、不懂

$PWD的:


      22 # rm -f .[^.]* ..?*   to remove filenames beginning with multiple

dots.      23 # (shopt -s dotglob; rm -f *)   will also work.

      24 # Thanks, S.C. for pointing this out.

10、不懂$SHELLOPTS的用法


[mdx@localhost abs-exercises]$ echo $SHELLOPTS

braceexpand:emacs:hashall:histexpand:history:interactive-comments:monitor

11、$SHLVL的用法


$SHLVL

    Shell level, how deeply Bash is nested. If, at the command line, $SHLVL is

    1, then in a script it will increment to 2.

12、$TMOUT的用法不懂,例子example9-2~9-4不懂

13、$UID,下面这段话的意思不懂

This is the current user's real id, even if she has temporarily assumed

    another identity through su.

14、example9-7太复杂了,留在这里备忘


    Caution The $* and $@ parameters sometimes display inconsistent and

            puzzling behavior, depending on the setting of $IFS.

    ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

    Example 9-7. Inconsistent $* and $@ behavior

15、set命令的用法


[mdx@localhost abs-exercises]$ set a b c

[mdx@localhost abs-exercises]$ echo $1 $2 $3

a b c

[mdx@localhost abs-exercises]$

16、$!的用法

书上的例子:

LOG=$0.log

COMMAND1="sleep 100"

echo "Logging PIDs background commands for script: $0" >> "$LOG"

# So they can be monitored, and killed as necessary.

echo >> "$LOG"

# Logging commands.

echo -n "PID of \"$COMMAND1\":  " >> "$LOG"

${COMMAND1} &

echo $! >> "$LOG"

# PID of "sleep 100":  1506

# Thank you, Jacques Lederer, for suggesting this.

#下面这句不大懂:eval, kill -9

#possibly_hanging_job & { sleep ${TIMEOUT}; eval 'kill -9 $!' &> /dev/null; }      

# Forces completion of an ill-behaved program.

# Useful, for example, in init scripts.

# Thank you, Sylvain Fourmanoit, for this creative use of the "!" varia

英语疑问:

1、subtleties, nuances

This requires learning their subtleties and nuances.

2、necessarily

$SHELL does not necessarily give the correct answer.

3、collation order, mishandled

$LC_COLLATE

    Often set in the .bashrc or /etc/profile files, this variable controls

    collation order in filename expansion and pattern matching. If mishandled,

    LC_COLLATE can cause unexpected results in filename globbing.

4、revert, customary

To revert to the customary behavior of bracket matching, set LC_COLLATE to C by an export LC_COLLATE=C in /etc/profile and/or ~/.bashrc.

5、expedient

In a script, it may be expedient to temporarily add a directory to the path

    in this way.

6、likewise

         $SHELL, the name of the user's login shell, may be set from /

         etc/passwd or in an "init" script, and it is likewise not a

         Bash builtin.

8.2. Numerical Constants

8.2. Numerical Constants

1、Example 8-4. Representation of numerical constants

同C语言一样,字符也是整数。但是@和_代表是多少不知道?而且把它们转化为十进制的方法忘记了。

  32 let "b64 = 64#@_"

  33 echo "base-64 number = $b64"             # 4031

  34 # This notation only works for a limited range (2 - 64) of ASCII characters  35 # 10 digits + 26 lowercase characters + 26 uppercase characters + @ + _

  36

  37

  38 echo

  39

  40 echo $((36#zz)) $((2#10101010)) $((16#AF16)) $((53#1aA))

  41                                          # 1295 170 44822 3375

英语疑难: evaluates

A number with an embedded # evaluates as BASE#NUMBER (with range and notational restrictions).

8.1. Operators

Chapter 8. Operations and Related Topics

8.1. Operators

1、Example 8-1. Greatest common divisor最大公约数的算法不懂,里面的练习:判断命令行参数是否是整数不懂,记在这里。

2、发现一个问题,bash的算术操作符只能进行整数的运算,要进行其它的复杂点的运算:如开方、小数等怎么办呢?

3、Example 8-2. Using Arithmetic Operations

这个例子有不少地方不明白,记在这里以后进一步解决:

我知道 let "z = 2 + 3" 相当于 (( z = 2 + 3 )),根据:


Similar to the let command, the ((...)) construct permits arithmetic expansion

and evaluation.

1)、


      10 : $((n = $n + 1))

      11 #  ":" necessary because otherwise Bash attempts

      12 #+ to interpret "$((n = $n + 1))" as a command.

2)、      20 n=$(($n + 1))

3)、

      23 : $[ n = $n + 1 ]

      24 #  ":" necessary because otherwise Bash attempts

      25 #+ to interpret "$[ n = $n + 1 ]" as a command.

      26 #  Works even if "n" was initialized as a string.

4)、

      29 n=$[ $n + 1 ]

      30 #  Works even if "n" was initialized as a string.

      31 #* Avoid this type of construct, since it is obsolete and

nonportable.

      32 #  Thanks, Stephane Chazelas.

5)、      44 : $(( n++ ))       # : $(( ++n )) also works.

6)、      47 : $[ n++ ]         # : $[ ++n ]] also works

4、bash不能处理浮点数:


Bash does not understand floating point arithmetic. It treats numbers containing a decimal point as strings.

5、

if [ $condition1 -a $condition2 ] 相当于 if [[ $condition1 && $condition2 ]]

,但是&&不能用在[...]结构中,这些有什么规律吗?真不好掌握啊。

6、Example 8-3. Compound Condition Tests Using && and ||


6 if [ "$a" -eq 24 ] && [ "$b" -eq 47 ]

17 #  Note:  if [[ $a -eq 24 && $b -eq 24 ]]  works.

20 #    (The "&&" has a different meaning in line 17 than in line 6.)

我不懂&&在6行和17行有什么区别?

7、不懂 $((...))的用法


     bash$ echo $(( 1 && 2 )) $((3 && 0)) $((4 || 0)) $((0 || 0))

     1 0 1 0

英语疑问:

1、Modulo turns up surprisingly often in various numerical recipes.

2、erroneous

An operation that takes a variable outside these limits will give an erroneous result.

3、flip, relevant, fly

"Bit flipping" is more relevant to compiled languages, such

as C and C++, which run fast enough to permit its use on the fly.

4、miscellaneous operators

5、evaluated

All the operations are evaluated (with possible side effects), but only the last operation is returned.

7.4. Nested if/then Condition Tests 7.5. Testing Your Knowledge of Tests

7.4. Nested if/then Condition Tests

嵌套条件测试相当于复合条件测试中的 &&

7.5. Testing Your Knowledge of Tests


  10      if [ -f /usr/bin/netscape -a -f /usr/share/doc/HTML/index.html ]; then  11              netscape /usr/share/doc/HTML/index.html &

  12      fi

有2个问题:

1、在测试条件中多个测试条件(如上:-f -a -f)的组合规则和形式是怎么样的?

2、"netscape /usr/share/doc/HTML/index.html &"后面加一个&是什么意思?

另外,这章布置了习题,分析/etc/X11/xinit/xinitrc文件中的条件语句,这遍就略过习题了。下同。

英语疑问:

1、excerpt

This file contains quite a number of if/then tests, as the following excerpt shows.

2、failsafe, fallbacks

 # failsafe settings.  Although we should never get here

 # (we provide fallbacks in Xclients as well) it can't hurt.