gpt4 book ai didi

linux - 我如何使用 execv() 编写这个 rm -rf/path/to/directory/* ?

转载 作者:太空宇宙 更新时间:2023-11-04 05:49:55 26 4
gpt4 key购买 nike

这将删除整个目录

This will delete the entire directory

rm -rf/path/to/directory/* 删除目录中的所有内容,但我不知道如何使用 execv() 编写此命令。

最佳答案

祝你好运

 #include <unistd.h>
#include <stdio.h>
#include <string.h>

int main(int argc, char *argv[])
{

char *params[4] = {"/bin/rm", "-rf", argv[1]};

int res = execv( "/bin/rm" , params);

return 0;
}

关于linux - 我如何使用 execv() 编写这个 rm -rf/path/to/directory/* ?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43980789/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com