2013年3月19日 星期二 中午小雪



引号



1、单引号



[root@desktop7 ~]# echo '\$a'


\$a


[root@desktop7 ~]# echo "\\\$a"


\$a



单引号:转义单引号中的所有字符含义


赋值验证



[root@desktop7 ~]# a=88


[root@desktop7 ~]# echo "$a"


88


[root@desktop7 ~]# echo '$a'


$a



2、反引号



[root@desktop7 ~]# echo `date`


Tue Mar 19 02:45:40 CST 2013


[root@desktop7 ~]#



反引号:引命令,取命令的结果



[root@desktop7 ~]# `date`


bash: Tue: command not found


[root@desktop7 ~]#



[root@desktop7 ~]# date +%Y                       #年


2013


[root@desktop7 ~]# date +%y                       #年


13


[root@desktop7 ~]# date +%m                       #月


03


[root@desktop7 ~]# date +%h                       #月


Mar


[root@desktop7 ~]# date +%d                       #日


19


[root@desktop7 ~]# date +%H                       #小时


02


[root@desktop7 ~]# date +%M                       #分钟


50


[root@desktop7 ~]# date +%S                       #秒


05


[root@desktop7 ~]# date


Tue Mar 19 02:50:23 CST 2013



[root@desktop7 ~]# date +%Y-%m-%d


2013-03-19



查看/etc下所有变量



[root@desktop7 ~]# A=`ls /etc*`


[root@desktop7 ~]# echo $A


acpi adjtime aliases aliases.db alsa alternatives anacrontab anthy-conf asound.state at.deny audisp audit autofs_ldap_auth.conf auto.master auto.misc auto.net auto.smb avahi bashrc blkid bluetooth bonobo-activation cdrecord.conf conman.conf cron.d cron.daily cron.deny cron.hourly cron.monthly crontab cron.weekly csh.cshrc csh.login cups dbus-1 default depmod.d desktop-profiles dev.d dhcp6c.conf DIR_COLORS DIR_COLORS.xterm dnsmasq.conf dnsmasq.d dumpdates environment esd.conf ethertypes exports fb.modes filesystems fonts foomatic fstab gconf gcrypt gdm ghostscript gnome-vfs-2.0 gnome-vfs-mime-magic gpm-root.conf gre.d group group- grub.conf gshadow gshadow- gssapi_mech.conf gtk-2.0 hal host.conf hosts hosts.allow hosts.deny hp httpd idmapd.conf init.d initlog.conf inittab inputrc iproute2 iscsi issue issue.net jwhois.conf krb5.conf ldap.conf ld.so.cache ld.so.conf ld.so.conf.d lftp.conf libaudit.conf libuser.conf libvirt localtime login.defs logrotate.conf logrotate.d logwatch lsb-release.d lvm mail mailcap mail.rc makedev.d man.config mcelog.conf mgetty+sendfax mime.types mke2fs.conf modprobe.conf modprobe.conf~ modprobe.d motd mtab mtools.conf multipath.conf Muttrc Muttrc.local netplug netplug.d NetworkManager nscd.conf nsswitch.conf ntp ntp.conf ntp.conf.predhclient oddjob oddjobd.conf oddjobd.conf.d openldap opt pam.d pam_pkcs11 pam_smb.conf pango passwd passwd- pcmcia Pegasus pinforc pki pm ppp prelink.cache prelink.conf prelink.conf.d printcap profile profile.d protocols purple quotagrpadmins quotatab racoon rc rc0.d rc1.d rc2.d rc3.d rc4.d rc5.d rc6.d rc.d rc.local rc.sysinit readahead.d reader.conf reader.conf.d redhat-lsb redhat-release request-key.conf resolv.conf resolv.conf.predhclient rhgb rhsm rmt rpc rpm rsyslog.conf rwtab rwtab.d sane.d sasl2 scim scrollkeeper.conf scsi_id.config securetty security selinux sensors.conf services sestatus.conf setuptool.d sgml shadow shadow- shells skel slrn.rc smartd.conf smrsh snmp sound ssh stunnel sudoers sysconfig sysctl.conf syslog.conf tcsd.conf termcap udev updatedb.conf vimrc virc warnquota.conf wgetrc wpa_supplicant X11 xdg xinetd.d xml yp.conf yum yum.conf yum.repos.d



对比



[root@desktop7 ~]# B=/etc/*


[root@desktop7 ~]# echo $B


/etc/acpi /etc/adjtime /etc/aliases /etc/aliases.db /etc/alsa /etc/alternatives /etc/anacrontab /etc/anthy-conf /etc/asound.state /etc/at.deny /etc/audisp /etc/audit /etc/autofs_ldap_auth.conf /etc/auto.master /etc/auto.misc /etc/auto.net /etc/auto.smb /etc/avahi /etc/bashrc /etc/blkid /etc/bluetooth /etc/bonobo-activation /etc/cdrecord.conf /etc/conman.conf /etc/cron.d /etc/cron.daily /etc/cron.deny /etc/cron.hourly /etc/cron.monthly /etc/crontab /etc/cron.weekly /etc/csh.cshrc /etc/csh.login /etc/cups /etc/dbus-1 /etc/default /etc/depmod.d /etc/desktop-profiles /etc/dev.d /etc/dhcp6c.conf /etc/DIR_COLORS /etc/DIR_COLORS.xterm /etc/dnsmasq.conf /etc/dnsmasq.d /etc/dumpdates /etc/environment /etc/esd.conf /etc/ethertypes /etc/exports /etc/fb.modes /etc/filesystems /etc/fonts /etc/foomatic /etc/fstab /etc/gconf /etc/gcrypt /etc/gdm /etc/ghostscript /etc/gnome-vfs-2.0 /etc/gnome-vfs-mime-magic /etc/gpm-root.conf /etc/gre.d /etc/group /etc/group- /etc/grub.conf /etc/gshadow /etc/gshadow- /etc/gssapi_mech.conf /etc/gtk-2.0 /etc/hal /etc/host.conf /etc/hosts /etc/hosts.allow /etc/hosts.deny /etc/hp /etc/httpd /etc/idmapd.conf /etc/init.d /etc/initlog.conf /etc/inittab /etc/inputrc /etc/iproute2 /etc/iscsi /etc/issue /etc/issue.net /etc/jwhois.conf /etc/krb5.conf /etc/ldap.conf /etc/ld.so.cache /etc/ld.so.conf /etc/ld.so.conf.d /etc/lftp.conf /etc/libaudit.conf /etc/libuser.conf /etc/libvirt /etc/localtime /etc/login.defs /etc/logrotate.conf /etc/logrotate.d /etc/logwatch /etc/lsb-release.d /etc/lvm /etc/mail /etc/mailcap /etc/mail.rc /etc/makedev.d /etc/man.config /etc/mcelog.conf /etc/mgetty+sendfax /etc/mime.types /etc/mke2fs.conf /etc/modprobe.conf /etc/modprobe.conf~ /etc/modprobe.d /etc/motd /etc/mtab /etc/mtools.conf /etc/multipath.conf /etc/Muttrc /etc/Muttrc.local /etc/netplug /etc/netplug.d /etc/NetworkManager /etc/nscd.conf /etc/nsswitch.conf /etc/ntp /etc/ntp.conf /etc/ntp.conf.predhclient /etc/oddjob /etc/oddjobd.conf /etc/oddjobd.conf.d /etc/openldap /etc/opt /etc/pam.d /etc/pam_pkcs11 /etc/pam_smb.conf /etc/pango /etc/passwd /etc/passwd- /etc/pcmcia /etc/Pegasus /etc/pinforc /etc/pki /etc/pm /etc/ppp /etc/prelink.cache /etc/prelink.conf /etc/prelink.conf.d /etc/printcap /etc/profile /etc/profile.d /etc/protocols /etc/purple /etc/quotagrpadmins /etc/quotatab /etc/racoon /etc/rc /etc/rc0.d /etc/rc1.d /etc/rc2.d /etc/rc3.d /etc/rc4.d /etc/rc5.d /etc/rc6.d /etc/rc.d /etc/rc.local /etc/rc.sysinit /etc/readahead.d /etc/reader.conf /etc/reader.conf.d /etc/redhat-lsb /etc/redhat-release /etc/request-key.conf /etc/resolv.conf /etc/resolv.conf.predhclient /etc/rhgb /etc/rhsm /etc/rmt /etc/rpc /etc/rpm /etc/rsyslog.conf /etc/rwtab /etc/rwtab.d /etc/sane.d /etc/sasl2 /etc/scim /etc/scrollkeeper.conf /etc/scsi_id.config /etc/securetty /etc/security /etc/selinux /etc/sensors.conf /etc/services /etc/sestatus.conf /etc/setuptool.d /etc/sgml /etc/shadow /etc/shadow- /etc/shells /etc/skel /etc/slrn.rc /etc/smartd.conf /etc/smrsh /etc/snmp /etc/sound /etc/ssh /etc/stunnel /etc/sudoers /etc/sysconfig /etc/sysctl.conf /etc/syslog.conf /etc/tcsd.conf /etc/termcap /etc/udev /etc/updatedb.conf /etc/vimrc /etc/virc /etc/warnquota.conf /etc/wgetrc /etc/wpa_supplicant /etc/X11 /etc/xdg /etc/xinetd.d /etc/xml /etc/yp.conf /etc/yum /etc/yum.conf /etc/yum.repos.d


[root@desktop7 ~]#



查看虚拟机安装脚本



[root@desktop7 ~]# vim /root/Desktop/install-vserver



 40 LOOIP=$(ifconfig br0 |grep 'inet addr' |awk '{print $2}' |awk -F. '{print $4}')


 41 serverip=$((LOOIP+100))


 42 stationip=$((LOOIP+200))