Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bash #7

Open
gobomb opened this issue Sep 11, 2019 · 8 comments
Open

bash #7

gobomb opened this issue Sep 11, 2019 · 8 comments

Comments

@gobomb
Copy link
Owner

gobomb commented Sep 11, 2019

while true; do echo 1; sleep 2; done

@gobomb
Copy link
Owner Author

gobomb commented Sep 17, 2019

docker inspect -f '{{.State.Pid}}' [container_name_or_id] 拿到 PID

nsenter -t [PID] -n netstat 查看该容器监听的端口

nsenter --target [PID] --mount --uts --ipc --net --pid 可进入容器

@gobomb
Copy link
Owner Author

gobomb commented Sep 19, 2019

获取所有容器的ip

docker inspect --format='{{.Name}} - {{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' $(docker ps -aq)

@gobomb
Copy link
Owner Author

gobomb commented Sep 23, 2019

echo

-n do not output the trailing newline

@gobomb
Copy link
Owner Author

gobomb commented Oct 14, 2019

获取数组下标

Array=(a b c)

for i in "${!Array[@]}"; do
  echo ${Array[$i]}
  echo ${i}
done

输出结果:

a
0
b
1
c
2

@gobomb
Copy link
Owner Author

gobomb commented Oct 14, 2019

间接取值:

A=10
B=A
echo ${!B}
# 输出: 10

@gobomb
Copy link
Owner Author

gobomb commented Oct 28, 2019

不解压看压缩包内容

tar tvf file.tar

@gobomb
Copy link
Owner Author

gobomb commented Oct 30, 2019

set -e 一有错误就退出, set -x 输出执行的命令

@gobomb
Copy link
Owner Author

gobomb commented May 7, 2020

grep -rn "hello,world!" ./

在文件中搜索字符串

@gobomb gobomb mentioned this issue Mar 3, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant