页面“Mtp on kcptun”与“Sed skill”之间的差异

来自linux中国网wiki
(页面间的差异)
跳到导航 跳到搜索
 
 
第1行: 第1行:
[[category:ops]] [[category:mtp]]
 
=国外节点 安装  mtp and  kcptun server =
 
  
==安装  mtp==
 
<pre>
 
bash <(wget -qO- https://git.io/mtg.sh)
 
mtg
 
  
得到 国外节点的mtp info  
+
==常用==
 +
  sed -i "s/netstat/\/usr\/bin\/netstat/g" check.sh  #还有一种不能转义的 是# ?
  
https://t.me/proxy?port=15854&secret=ee579b292c6e87db4d0e1ac6dcb598b1d062696e672e636f6&server=109.182.27.193
+
==!==
</pre>
 
 
 
==kcpturn server  ==
 
 
<pre>
 
<pre>
os init
+
[root@localhost ~]# cat  /var/spool/cron/root
 +
*/2  *  *  *  *    /root/check.sh
  
ulimit -n 65535, or write it in ~/.bashrc.
+
[root@localhost ~]# sed -i 's!*/2!#*!' /var/spool/cron/root
  
Suggested sysctl.conf parameters for better handling of UDP packets:
+
[root@localhost ~]# cat  /var/spool/cron/root
 +
#*  *  *  *  *    /root/check.sh
  
net.core.rmem_max=26214400
+
</pre>
net.core.rmem_default=26214400
 
net.core.wmem_max=26214400
 
net.core.wmem_default=26214400
 
net.core.netdev_max_backlog=2048
 
  
 +
==sed 指定行后添加行==
 +
<pre>在29行之后添加
 +
sed -i '29a user=mysql' /etc/my.cnf
 +
sed -i '29a character-set-server=utf8' /etc/my.cnf
 +
sed -i '29ainnodb_file_per_table=1' /etc/my.cnf</pre>
  
app install
+
==sed删除指定行的注释==
wget    https://github.com/xtaci/kcptun/releases/download/v20201126/kcptun-linux-amd64-20201126.tar.gz
+
<pre>#ln36
 +
sed -i -e '36 s/^#//' file </pre>
  
 +
==#ln1 to ln6==
 +
sed -i -e '1,6 s/^#//' file
  
wget  -c    https://github.com/xtaci/kcptun/releases/download/v20201126/kcptun-linux-386-20201126.tar.gz
 
  
./server_linux_386 -l :80 -t 127.0.0.1:15854 -key eller -mtu 1400 -sndwnd 2048 -rcvwnd 2048 -mode fast2 -sockbuf 16777217  2>&1 &</pre>
+
==sed 替换并插入==
 +
  sed -i 's!old!new!' filename
  
= 国内节点 安装 kcptun client =
+
==[[Sed删除或者替换有关键字的一行]]==
  
/root/kcptun/client_linux_amd64 -l :80 -r 107.182.27.193:80 -key eller -mtu 1400 -sndwnd 256 -rcvwnd 2048 -mode fast2 -conn 4  -sockbuf 16777217  2>&1 &
+
=追加不太像==
 +
<pre>
  
 +
所有192.168.0.1 开头的行都被替换成它自己加localhost  192.168.0.1localhost                                                                                                 
 +
sed  's/^192.168.0.1/&localhost/' filename                                                                                                                                 
 +
                                                                                                                                                                           
 +
                                                                                                                                                                           
 +
evan@myxps:~/tmp$ cat e.txt                                                                                                                                               
 +
i1111                                                                                                                                                                     
 +
2222                                                                                                                                                                       
 +
                                                                                                                                                                           
 +
                                                                                                                                                                           
 +
                                                                                                                                                                           
 +
                                                                                                                                                                           
 +
                                                                                                                                                                           
 +
3333                                                                                                                                                                       
 +
evan@myxps:~/tmp$ sed -i  -n 's/^i1/&love/p' e.txt                                                                                                                         
 +
evan@myxps:~/tmp$ cat e.txt                                                                                                                                               
 +
i1love111                                                                                                                                                                 
 +
           
 +
</pre>
 +
==sed 使用shell变量 ==
 +
如果要使用shell变量,就需要使用双引号
 +
 +
=sed also=
  
最后用了国内节点的 mtp 如下
+
[https://blog.csdn.net/stpeace/article/details/46730991 sed基本用法简介]
https://t.me/proxy?port=80&secret=ee579b292c6e87db4d0e1ac6dcb598b1d062696e672e636f6&server=110.231.144.243
 
=trouble shooting=
 
<pre>
 
./server_linux_amd64
 
-bash: ./server_linux_amd64: cannot execute binary file: Exec format error
 
  
uname -a
+
[http://kodango.com/sed-and-awk-notes-part-2 Sed and awk 笔记之 sed 篇:模式空间与地址匹配]
Linux vibrant-pipe-1.localdomain 4.19.0-5-686-pae #1 SMP Debian 4.19.37-5+deb10u2 (2019-08-08) i686 GNU/Linux
 
root@vibrant-pipe-1:/data/apps#
 
  
 +
[https://www.cnblogs.com/taosim/p/4000528.html sed awk插入,替换指定行的特定字符串,删除指定行首的]
  
领导搞了个 32 bit机子 
+
[https://baike.xsoftlab.net/view/595.html Linux使用sed删除和替换文件中某一行的方法]
</pre>
 
  
=see also=
+
[[category:ops]] [[category:shell]]
https://github.com/xtaci/kcptun
 

2020年12月11日 (五) 07:28的版本


常用

 sed  -i "s/netstat/\/usr\/bin\/netstat/g" check.sh  #还有一种不能转义的 是# ?

!

[root@localhost ~]# cat  /var/spool/cron/root 
*/2  *  *  *  *    /root/check.sh

[root@localhost ~]# sed -i 's!*/2!#*!' /var/spool/cron/root

[root@localhost ~]# cat  /var/spool/cron/root 
#*  *  *  *  *    /root/check.sh

sed 指定行后添加行

在29行之后添加
sed -i '29a user=mysql' /etc/my.cnf
sed -i '29a character-set-server=utf8' /etc/my.cnf
sed -i '29ainnodb_file_per_table=1' /etc/my.cnf

sed删除指定行的注释

#ln36
sed -i -e '36 s/^#//' file 

#ln1 to ln6

sed -i -e '1,6 s/^#//' file


sed 替换并插入

sed -i 's!old!new!' filename

Sed删除或者替换有关键字的一行

追加不太像=


所有192.168.0.1 开头的行都被替换成它自己加localhost  192.168.0.1localhost                                                                                                   
 sed  's/^192.168.0.1/&localhost/' filename                                                                                                                                  
                                                                                                                                                                             
                                                                                                                                                                             
 evan@myxps:~/tmp$ cat e.txt                                                                                                                                                 
 i1111                                                                                                                                                                       
 2222                                                                                                                                                                        
                                                                                                                                                                             
                                                                                                                                                                             
                                                                                                                                                                             
                                                                                                                                                                             
                                                                                                                                                                             
 3333                                                                                                                                                                        
 evan@myxps:~/tmp$ sed -i  -n 's/^i1/&love/p' e.txt                                                                                                                          
 evan@myxps:~/tmp$ cat e.txt                                                                                                                                                 
 i1love111                                                                                                                                                                   
             

sed 使用shell变量

如果要使用shell变量,就需要使用双引号

sed also

sed基本用法简介

Sed and awk 笔记之 sed 篇:模式空间与地址匹配

sed awk插入,替换指定行的特定字符串,删除指定行首的

Linux使用sed删除和替换文件中某一行的方法