当前位置:网站首页>Pipes and xargs
Pipes and xargs
2022-04-23 20:59:00 【Sleeping snail】
ps aux|grep deltest|grep -v grep|awk '{print $2}'|xargs kill -9ps aux Will list all processes , The next pipe will pass the result to the second command
The second command looks for... From the result of the first command deltest
The third command is to filter the text backwards , Will include grep The deletion of
The fourth command will read the second column of data of the result deleted by the third command ,awk By default, they are separated by spaces
xargs A command is a filter used to pass parameters to other commands , It's also a tool for combining multiple commands .
Successful conversion of standard input data command line parameters can convert the data in the pipeline or standard input into command line parameters of specific commands
The fifth command will treat the previous command as kill And then kill
xargs
If you want to run a file in the current directory , have access to python3 `pwd`/deltest2.py
You can also use pwd | xargs -I {} python3 {}/deltest2.py
This -I{} It should be to put the content from the front into {}, Then use it again {} For the use of
and echo `pwd|xargs -I {} python3 {}/$element` It should be that you want to output the return value of the run , If the program keeps running , Then it will always wait .
Let multiple programs run sh command
#!/bin/bash
array=("deltest2.py" "deltest.py")
cd /workplace/kill_test
nowpath='/workplace/kill_test/'
for element in ${array[@]}
do
echo $element
nohup pwd|xargs -I {} python3 {}/$element &
sstr=$(echo -e $str)
echo $sstr
done
Batch stop program
#!/bin/bash
# Try to write a fully running program , You'd better add the suffix There are no commas between array elements
array=("deltest2.py" "deltest.py")
for element in ${array[@]}
do
ps aux|grep $element|grep -v grep|awk '{print $2}'|xargs kill -9
done
版权声明
本文为[Sleeping snail]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/113/202204232049234446.html
边栏推荐
- MySQL进阶之表的增删改查
- 居家第二十三天的午饭
- Detailed explanation of basic assembly instructions of x86 architecture
- Factory mode
- Sequential state
- Use 3080ti to run tensorflow GPU = 1 X version of the source code
- presto on spark 支持3.1.3记录
- Arm architecture assembly instructions, registers and some problems
- Realrange, reduce, repeat and einops in einops package layers. Rearrange and reduce in torch. Processing methods of high-dimensional data
- airbase 初步分析
猜你喜欢
小米手机全球已舍弃“MI”品牌,全面改用“xiaomi”全称品牌
Graph traversal - BFS, DFS
亚马逊和Epic将入驻,微软应用商城向第三方开放
1. Finishing huazi Mianjing -- 1
Centos7 builds MySQL master-slave replication from scratch (avoid stepping on the pit)
Rust更适合经验较少的程序员?
又一款数据分析神器:Polars 真的很强大
管道和xargs
Win 11K in 100 days, super complete learning guide for job transfer test
PHP的Laravel与Composer部署项目时常见问题
随机推荐
100天拿下11K,转岗测试的超全学习指南
C# 知识
Question brushing plan - depth first search (II)
ROS学习笔记-----ROS的使用教程
Thinkphp5 + data large screen display effect
Graph traversal - BFS, DFS
ros功能包内自定义消息引用失败
使用mbean 自动执行heap dump
启牛学堂有用吗,推荐的证券账户是否安全
setInterval、setTimeout、requestAnimationFrame
go array
Centralized record of experimental problems
C, print the source program of beautiful bell triangle
Some grounded words
Two Stage Detection
MySQL基础合集
Reentrant function
Question brushing plan -- backtracking method (I)
Deep analysis of C language pointer (Part I)
Sklearn function: Train_ Test_ Split (split training set and test set)