通过xshell批量处理多台服务器文本
发布时间:2023-8-28 14:43:29 来源: 纵横云
通过xshell批量处理多台服务器文本
1、首先我们在xshell中新建几个新的会话

2、然后连接上会话

3、点击查看—撰写栏—撰写选择

在底下会出现撰写栏然后选择全会话

4、我们在撰写栏输入 echo " 123456 " >> 123456.txt
可以看到每台服务器都新建了一个123456.txt的文件 并且文件内容都是123456


echo " 123456 " >> 123456.txt
这条命令是在文件追加内容,没有文件的话会先新建文件并输入内容
通过撰写栏我输入了5遍可以查看文件

echo " 123456 " > 123456.txt
是把文件覆盖并不会追加

5、使用sed 可以实现将文本插入(删除)文件第几行
执行sed -i "3i "haha"" 123456.txt 后我们可以看到123456.txt第三行被插入了haha
之后执行sed -i '3d' 123456.txt,可以看到第3行被删除,可以看到其他台也执行了这些命令


通过撰写栏使用命令更改文件这样我们就可以批量的处理不同服务器上的文件了。
本文来源:
https://www.zonghengcloud.com/article/12108.html
[复制链接]
链接已复制