![](https://img-blog.csdnimg.cn/20201014180756780.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
linux shell篇
linux脚本使用
凉风起天末、
螃蟹在剥我的壳,笔记本在写我;漫天的我落在枫叶上雪花上;而你在想我。
展开
-
shell教程–shell字符串
一、单引号(’’)1.单引号字符串的限制:单引号里的任何字符都会原样输出,单引号字符串中的变量是无效的;单引号字串中不能出现单独一个的单引号(对单引号使用转义符后也不行),但可成对出现,作为字符串拼接使用。[root@xsnq ~]# string=xsnq[root@xsnq ~]# echo '$string'$string二、双引号("")双引号的优点:双引号里可以有变量 ;双引号里可以出现转义字符。[root@xsnq ~]# string=xsnq[root@xs原创 2021-05-13 14:37:47 · 144 阅读 · 0 评论 -
Linux Shell远程执行命令(ssh)
使用前提:配置ssh免密码登陆(这里我已做了互信)一、对于几条命令:格式:ssh remote_username@remote_ip "remote_command"注释:remote_username 远程用户名remote_ip 目标服务器ipremote_command 操作在目标服务器上的指令这里单引号或双引号开头都可以,最后再用相同的引号来结束例:服务器一[root@xsnq ~]# ssh root@192.168.75.5 'touch /opt/xsnq.tx.原创 2021-03-03 11:57:08 · 7035 阅读 · 0 评论 -
shell教程–shell变量
实打实的“”):保留其中的变量属性,不进行转义处理。[root@xsnq ~]# a=xsnq[root@xsnq ~]# echo "$a"xsnq反引号(``):把其中的命令执行后返回结果。Esc下面那个键[root@xsnq ~]# pwd/root[root@xsnq ~]# echo `pwd`/rootEsc下面那个键[root@xsnq ~]# pwd/root[root@xsnq ~]# echo `pwd`/root...原创 2021-01-19 17:31:10 · 173 阅读 · 0 评论 -
shell教程–4种常用的转义字符
4种常用的转义字符反斜杠(\):使反斜杠后面的一个变量变为单纯的字符串。[root@xsnq ~]# echo "\"xsnq\"""xsnq"单引号(’’):转义其中所有的变量为单纯的字符串。[root@xsnq ~]# a=xsnq[root@xsnq ~]# echo $axsnq[root@xsnq ~]# echo '$a'$a双引号(""):保留其中的变量属性,不进行转义处理。[root@xsnq ~]# a=xsnq[root@xsnq ~]# echo原创 2021-01-19 15:49:10 · 4692 阅读 · 0 评论 -
shell教程--第一个shell脚本
第一个shell脚本进入 Linux 终端,编写一个 Shell 脚本,文件名为 hello.sh :#!/bin/bashcd /opt/echo "Hello World !".sh 不是强制要求的,常用扩展名为 sh代表shell,扩展名并不影响脚本执行。#! 告诉系统这个脚本需要什么解释器来执行。echo 命令用于向窗口输出文本。运行 1. 调用解释器执行 bash hello.sh 或者 sh hello.sh <==> /bin/bash hell原创 2021-01-19 15:27:24 · 462 阅读 · 0 评论