
bash
一念一生~one
这个作者很懒,什么都没留下…
展开
-
【Linux/shell】cat结合EOF脚本案例(20210110)
案例1:EOF常规用法#注意:cat后面可以带>或者>>; EOF完标准只能跟<<符号;cat >> /etc/hosts << EOF 192.168.50.128 master192.168.50.128 node0192.168.50.131 node1192.168.50.132 node2EOF案例2:带有符号$的前面一定要加上转义符\才行,否则产生的脚本中可能存在问题。cat > /root/shell2.sh&l原创 2021-01-10 20:10:37 · 635 阅读 · 0 评论 -
【Linux/shell】使用bash/sh file.sh、./file.sh 、source file.sh、. file.sh的区别(20210109)
#参考文章:https://blog.csdn.net/cju_277/article/details/112016245首先打印当前进程的父进程ID和当前进程的ID,分别使用如下命令:打印父进程ID: echo $PPID打印当前进程ID: echo $$现在把它写入脚本里面,如下所示:[root@centos76 ~]#cat test.sh #!/bin/bashecho " PPID: $PPID ,PID: $$"在执行之前,先来确定一下当前shell环境的PID号:[ro转载 2021-01-09 17:50:49 · 600 阅读 · 0 评论 -
【Linux】引用变量引号的问题(20210109)
大家来思考个简单的问题,echo如何输出连续的空格呢?(1)现象:默认下echo会进行合并;[root@centos76 ~]#cat b.sh a="a b"echo $a[root@centos76 ~]#bash b.sha b(2)解决办法:echo 的时候 加上双引号[root@centos76 ~]#cat b.sh a="a b"echo "$a"[root@centos76 ~]#bash b.sh a b总结:这个题主要是来说明原创 2021-01-09 15:01:23 · 469 阅读 · 0 评论 -
【Linux/shell】bash命令和sh命令的区别(20210109)
#注意,linux shell脚本中,首行不用指定bash类型也是可以的哦,默认就是bash,但一般是要标明bash类型的;#即:bash命令和sh命令一般是等效的;[root@centos76 ~]#cat b.sh a="a b"echo $a[root@centos76 ~]#bash b.sh #bash命令a b[root@centos76 ~]#sh b.sh #sh命令a b[root@centos76 ~]#cat c.sh #一般shll脚本首行建议标明ba原创 2021-01-09 14:50:14 · 2022 阅读 · 0 评论 -
【Linux/shell】cat结合EOF脚本案例(20210109)
案例1:EOF常规用法cat >>/etc/hosts <<EOF192.168.50.128 master192.168.50.128 node0192.168.50.131 node1192.168.50.132 node2EOF案例2:带有符号$的前面一定要加上转义符\才行。cat > /root/shell2.sh<< EOF for((i=1;i<=100;i++));doecho \原创 2021-01-09 14:03:53 · 790 阅读 · 0 评论 -
【shell脚本】Centos7离线rpm软件包升级内核脚本-20210107
(1)下载新版本kernel image的rpm软件包下载地址:centos7:http://elrepo.org/linux/kernel/el7/x86_64/RPMS/上传2个内核rpm软件包到linux系统下:(2)先查看原系统内核版本[root@localhost ~]# uname -r #查看内核版本[root@localhost ~]# ll -h /boot/vmlinuz-* #查看内核大小及位置#注意启动过程中,这边也是可以看到内核版本的;默认这里有2个内核,一个是原创 2021-01-07 22:36:35 · 534 阅读 · 0 评论 -
【Linux/shell】命令行扩展:`` 和 $()以及单引号’’ 双引号””区别
[root@test ~]# echo "please reboot your system quick"please reboot your system quick[root@test ~]# echo "please reboot your system quick!!!"-bash: !": event not found[root@test ~]# echo "please reboot your system quick!"-bash: !": event not found[r.原创 2021-01-07 21:03:30 · 424 阅读 · 0 评论 -
bash脚本winodws下编写上传到linux下格式存在问题解决办法-20210106
【Linux】关于bash脚本winodws下编写上传到linux下格式存在问题测试过程及解决办法如下当时这个ssh8.3_Update.sh文件是在windows下用sublime文件编辑的:但是把这个文件上传到linux下,用cat -v xx查看就会发现次脚本出现问题:每行的行位都会出现“托字符”:用如下命令清除后,再次查看发现就正常了(除了用汉字备注的):[root@centos76 ~]#sed -i "s/^M//g" ssh8.3_Update.sh注意:中间那个字符是用ctr原创 2021-01-06 22:59:20 · 305 阅读 · 2 评论