当前位置:网站首页>awk从入门到入土(15)awk执行外部命令
awk从入门到入土(15)awk执行外部命令
2022-07-04 08:38:00 【奇妙之二进制】
这里的外部命令,是指shell命令。
方法1
如果不需要获取命令的输出而只是需要执行命令可以使用system()函数。
#!/usr/bin/awk -f
BEGIN {
system("touch test");
}
命令字符串必须由“”括起来。
甚至还能判断命令是否成功执行:
BEGIN{
fold = "/tmp/test";
# 调用系统命令mkdir创建文件夹
res = system("mkdir " fold);
print("res: " res);
if ( 0 == res ) {
print("文件夹创建成功");
}
# 再次创建同样的文件夹
res = system("mkdir " fold);
print("res: " res);
if ( 0 != res ) {
print("文件夹创建失败");
}
}
{
}
END{
}
方法2
"ls" | getline var
var是变量名,可以省略,相当于会将命令的执行结果赋值给var。
边栏推荐
- Technology sharing | MySQL parallel DDL
- Unity-Text上标平方表示形式+text判断文本是否为空
- 【性能測試】一文讀懂Jmeter
- Take you to master the formatter of visual studio code
- How to play dapr without kubernetes?
- ctfshow web255 web 256 web257
- go-zero微服务实战系列(九、极致优化秒杀性能)
- C#,数值计算(Numerical Recipes in C#),线性代数方程的求解,Gauss-Jordan消去法,源代码
- Educational Codeforces Round 115 (Rated for Div. 2)
- How to solve the problem that computers often flash
猜你喜欢
[performance test] read JMeter
go-zero微服务实战系列(九、极致优化秒杀性能)
【性能测试】一文读懂Jmeter
根据数字显示中文汉字
墨者学院-PHPMailer远程命令执行漏洞溯源
How can we make a monthly income of more than 10000? We media people with low income come and have a look
Sqli labs download, installation and reset of SQL injection test tool one of the solutions to the database error (# 0{main}throw in d:\software\phpstudy_pro\www\sqli labs-...)
[CV] Wu Enda machine learning course notes | Chapter 9
How to solve the problem of computer jam and slow down
Redis 哨兵机制
随机推荐
Openfeign service interface call
一文了解数据异常值检测方法
WordPress get_ Users() returns all users with comparison queries - PHP
[performance test] read JMeter
Codeforces Global Round 21(A-E)
Flutter 集成 amap_flutter_location
[BSP video tutorial] stm32h7 video tutorial phase 5: MDK topic, system introduction to MDK debugging, AC5, AC6 compilers, RTE development environment and the role of various configuration items (2022-
Figure guessing game
没有Kubernetes怎么玩Dapr?
yolov5 xml数据集转换为VOC数据集
Cannot click button when method is running - C #
Famous blackmail software stops operation and releases decryption keys. Most hospital IOT devices have security vulnerabilities | global network security hotspot on February 14
Comprendre la méthode de détection des valeurs aberrantes des données
1. Kalman filter - the best linear filter
C#实现一个万物皆可排序的队列
std::is_ union,std::is_ class,std::integral_ constant
Using the rate package for data mining
Group programming ladder race - exercise set l2-002 linked list de duplication
How to set multiple selecteditems on a list box- c#
How to solve the problem of computer jam and slow down