当前位置:网站首页>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。
边栏推荐
- Leetcode 146. LRU 缓存
- 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
- Learn nuxt js
- 1. Getting started with QT
- Redis 哨兵机制
- Show server status on Web page (on or off) - PHP
- How to improve your system architecture?
- Add log file to slim frame - PHP
- 没有Kubernetes怎么玩Dapr?
猜你喜欢

manjaro安装微信

What should I do if there is a problem with the graphics card screen on the computer

没有Kubernetes怎么玩Dapr?

Unity text superscript square representation +text judge whether the text is empty

How does Xiaobai buy a suitable notebook

Conversion of yolov5 XML dataset to VOC dataset

Unity-Text上标平方表示形式+text判断文本是否为空

Wechat has new functions, and the test is started again

Do you know about autorl in intensive learning? A summary of articles written by more than ten scholars including Oxford University and Google

广和通高性能4G/5G无线模组解决方案全面推动高效、低碳智能电网
随机推荐
High order phase difference such as smear caused by myopic surgery
Mouse over to change the transparency of web page image
How to use C language code to realize the addition and subtraction of complex numbers and output structure
Manjaro install wechat
Private collection project practice sharing [Yugong series] February 2022 U3D full stack class 007 - production and setting skybox resources
yolov5 xml数据集转换为VOC数据集
string. Format without decimal places will generate unexpected rounding - C #
没有Kubernetes怎么玩Dapr?
From scratch, use Jenkins to build and publish pipeline pipeline project
根据数字显示中文汉字
[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-
运动【跑步 01】一个程序员的半马挑战:跑前准备+跑中调整+跑后恢复(经验分享)
Moher College webmin unauthenticated remote code execution
Go h*ck yourself:online reconnaissance (online reconnaissance)
Laravel page load problem connection reset - PHP
[Chongqing Guangdong education] National Open University spring 2019 455 logistics practice reference questions
一文了解数据异常值检测方法
C#,数值计算(Numerical Recipes in C#),线性代数方程的求解,Gauss-Jordan消去法,源代码
Learn nuxt js
学习Nuxt.js