Skip to content

ztoiax/userfulscripts

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

53 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Useful scripts

tmp script ,可避免因输错路径导致 rm -rf 的错误删除 tmp.sh

similar mv file /tmp

  • 如果 tmp 路径下已经存在该文件,则会在文件名后面加入日期
# useage
tmp.sh file

因为/tmp 是内存文件系统,系统会自动删除,可以减少 IO 的开销,代价是内存的减少,不适合大文件

因此建议使用trash-cli,类似于 windows 的回收站,只是把文件移动到一个目录里,并不会真正删除文件

compress and decompress

support type:

  • 7z
  • gz
  • bz2
  • zip
  • rar
  • zip
  • xz
  • lz4
  • zstd

fast pack and compress script mytar.sh

Automatically determine the file extension name for compression Automatically switch pigz or gz,pbzip2 or bzip2

# show example:
mytar.sh

# view file contents
mytar.sh filename.zip
mytar.sh filename.xz
mytar.sh filename.lz4

# Compress a single file:
mytar.sh filename.zip file
mytar.sh filename.xz file
mytar.sh filename.7z file
mytar.sh filename.zst file

# tar and compress single or multiple directories:
mytar.sh filename.tar.gz /home /etc
mytar.sh filename.tar.xz /home /etc
mytar.sh filename.tar.lz4 /home /etc
mytar.sh filename.tar.zst /home /etc

show compression ratio:

  • less than 100% is green image

  • greater than 100% is red image

simple compression benchmark:

mytar.sh test.tar.gz  /tmp/jianli /tmp/dwm
mytar.sh test.tar.bz2 /tmp/jianli /tmp/dwm
mytar.sh test.tar.xz  /tmp/jianli /tmp/dwm
mytar.sh test.7z      /tmp/jianli /tmp/dwm
  • xz is slow but ratio is good

  • 7z is fast and best

    image

Multithreading compression and decompression:

  • pigz

  • bzip2

  • pixz

    The above window shows the utilization useage of all CPU cores

    common gz compressing: image

    pigz compressing: image

More compress benchmark:

decompress script myx.sh

# single file
myx.sh filename.tar.gz
myx.sh filename.7z

# decompress mutile file
myx.sh filename.7z filename.tar.gz

top completion mytop.sh

image

tech search engine

search iptable
#output
[1] Github
[2] IBM developer
[3] 华为技术支持
[4] Gitbook
[5] 阿里云社区
[6] archwiki
[7] 简书
[8] 夸克
[9] 华三技术支持
[10] 思科
[11] pkgs
[12] linux中国
[13] python pypi
输入0则全部打开,输入编号则打开的搜索引擎:

多线程ping

ping -c 1 ip进行多线程包装, 判断主机是否存在

# 指定ip
ip_thread 192.168.1.1 192.168.1.111

# 扫描端口: -n
ip_thread -n 192.168.1.1 192.168.1.111

# 指定文件内的ip
ip_thread.py $(cat ip_file)

# 指定网段
ip_thread 192.168.1.0/24 192.168.2.0/24
  • 两者速度对比(我cpu是6核12线程)
for i in 192.168.1.{1..255}; do
    ping -c 1 $i
done
ip_thread.py 192.168.1.0/24
  • 多线程到61, 而普通的shell命令才到9 image

Releases

No releases published

Packages

No packages published