当前位置:网站首页>Awk from entry to earth (15) awk executes external commands
Awk from entry to earth (15) awk executes external commands
2022-07-04 08:46:00 【Wonderful binary】
External commands here , Refer to shell command .
Method 1
If you don't need to get the output of the command but just need to execute the command, you can use system() function .
#!/usr/bin/awk -f
BEGIN {
system("touch test");
}
The command string must consist of “” Cover up .
It can even judge whether the command was successfully executed :
BEGIN{
fold = "/tmp/test";
# Invoking system commands mkdir Create folder
res = system("mkdir " fold);
print("res: " res);
if ( 0 == res ) {
print(" Folder created successfully ");
}
# Create the same folder again
res = system("mkdir " fold);
print("res: " res);
if ( 0 != res ) {
print(" Folder creation failed ");
}
}
{
}
END{
}
Method 2
"ls" | getline var
var Is a variable name. , It can be omitted , It is equivalent to assigning the execution result of the command to var.
边栏推荐
- [Chongqing Guangdong education] National Open University spring 2019 455 logistics practice reference questions
- Four essential material websites for we media people to help you easily create popular models
- [attack and defense world | WP] cat
- Fault analysis | MySQL: unique key constraint failure
- Codeforces Round #803 (Div. 2)(A-D)
- Awk from entry to earth (12) awk can also write scripts to replace the shell
- DM8 uses different databases to archive and recover after multiple failures
- deno debugger
- Codeforces Global Round 21(A-E)
- [error record] no matching function for call to 'cacheflush' cacheflush();)
猜你喜欢
Codeforces Round #793 (Div. 2)(A-D)
DM8 command line installation and database creation
转:优秀的管理者,关注的不是错误,而是优势
[CV] Wu Enda machine learning course notes | Chapter 9
Codeforces Round #803 (Div. 2)(A-D)
Démarrage des microservices: passerelle
Educational Codeforces Round 115 (Rated for Div. 2)
Basic operations of databases and tables ----- view data tables
没有Kubernetes怎么玩Dapr?
09 softmax regression + loss function
随机推荐
Const string inside function - C #
A single element in an ordered array
Newh3c - routing protocol (RIP, OSPF)
没有Kubernetes怎么玩Dapr?
AI Winter Olympics | is the future coming? Enter the entrance of the meta universe - virtual digital human
Comprendre la méthode de détection des valeurs aberrantes des données
manjaro安装微信
C, Numerical Recipes in C, solution of linear algebraic equations, Gauss Jordan elimination method, source code
Openfeign service interface call
DM database password policy and login restriction settings
广和通高性能4G/5G无线模组解决方案全面推动高效、低碳智能电网
如何通过antd的upload控件,将图片以文件流的形式发送给服务器
How college students choose suitable computers
Technology sharing | MySQL parallel DDL
Conversion of yolov5 XML dataset to VOC dataset
SSRF vulnerability exploitation - attack redis
Leetcode topic [array] -136- numbers that appear only once
How to solve the problem of computer jam and slow down
DM8 uses different databases to archive and recover after multiple failures
How to send pictures to the server in the form of file stream through the upload control of antd