rmdir command usage

本文详细介绍Linux下rmdir命令的使用方法,包括语法、常用选项及实际操作案例,演示如何使用rmdir命令删除空目录。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

rmdir命令: remove empty directories 删除空文件夹。

语法: rmdir [OPTION]… DIRECTORY…
常用选项:
-p: parent 删除一脉单传的文件夹。
-v: verbose 详细信息,显示删除过程。
实例:

$tree ./guyang/
./guyang/
└── blog
	└── success
$rmdir -pv ./guyang/blog/success/
rmdir: removing directory, './guyang/blog/success/'
rmdir: removing directory, './guyang/blog'
rmdir: removing directory, './guyang'
rmdir: removing directory, '.'
rmdir: failed to remove directory '.': Invalid argument

说明:一次行删除一脉单传的空目录。删除过程如上所示。

$ rmdir ./guyang
说明:直接删除空目录,非空目录将报错。
ll.c:17:21: error: unknown type name ‘SystemState’ 17 | int find_free_block(SystemState* state) { | ^~~~~~~~~~~ ll.c:28:20: error: unknown type name ‘SystemState’ 28 | void mkdir_command(SystemState* state, const char* dirname) { | ^~~~~~~~~~~ ll.c:59:20: error: unknown type name ‘SystemState’ 59 | void rmdir_command(SystemState* state, const char* dirname) { | ^~~~~~~~~~~ ll.c:87:19: error: unknown type name ‘SystemState’ 87 | void edit_command(SystemState* state, const char* filename) { | ^~~~~~~~~~~ ll.c:134:22: error: unknown type name ‘SystemState’ 134 | void delfile_command(SystemState* state, const char* filename) { | ^~~~~~~~~~~ ll.c: In function ‘main’: ll.c:165:5: error: unknown type name ‘SystemState’ 165 | SystemState state = {0}; | ^~~~~~~~~~~ ll.c:166:5: warning: implicit declaration of function ‘init_filesystem’ [-Wimplicit-function-declaration] 166 | init_filesystem(&state); | ^~~~~~~~~~~~~~~ ll.c:168:16: error: ‘MAX_CMD_LEN’ undeclared (first use in this function) 168 | char input[MAX_CMD_LEN]; | ^~~~~~~~~~~ ll.c:168:16: note: each undeclared identifier is reported only once for each function it appears in ll.c:169:14: error: ‘MAX_NAME_LEN’ undeclared (first use in this function) 169 | char cmd[MAX_NAME_LEN]; | ^~~~~~~~~~~~ ll.c:172:5: warning: implicit declaration of function ‘show_help’ [-Wimplicit-function-declaration] 172 | show_help(); | ^~~~~~~~~ ll.c:175:34: error: request for member ‘current_user’ in something not a structure or union 175 | printf("\n%s:%s> ", state.current_user, state.current_dir->name); | ^ ll.c:175:54: error: request for member ‘current_dir’ in something not a structure or union 175 | printf("\n%s:%s> ", state.current_user, state.current_dir->name); | ^ ll.c:184:20: warning: implicit declaration of function ‘login’ [-Wimplicit-function-declaration] 184 | printf(login(&state) ? "Login successful\n" : "Login failed\n"); | ^~~~~ ll.c:187:13: warning: implicit declaration of function ‘cd_command’ [-Wimplicit-function-declaration] 187 | cd_command(&state, args >= 2 ? arg : NULL); | ^~~~~~~~~~ ll.c:190:13: warning: implicit declaration of function ‘dir_command’ [-Wimplicit-function-declaration] 190 | dir_command(&state, args >= 2 ? arg : NULL); | ^~~~~~~~~~~ ll.c:193:13: warning: implicit declaration of function ‘mkdir_command’ [-Wimplicit-function-declaration] 193 | mkdir_command(&state, arg); | ^~~~~~~~~~~~~ ll.c:196:13: warning: implicit declaration of function ‘rmdir_command’ [-Wimplicit-function-declaration] 196 | rmdir_command(&state, arg); | ^~~~~~~~~~~~~ ll.c:199:13: warning: implicit declaration of function ‘edit_command’ [-Wimplicit-function-declaration] 199 | edit_command(&state, arg); | ^~~~~~~~~~~~ ll.c:202:13: warning: implicit declaration of function ‘delfile_command’ [-Wimplicit-function-declaration] 202 | delfile_command(&state, arg); | ^~~~~~~~~~~~~~~ ll.c:214:5: warning: implicit declaration of function ‘cleanup_filesystem’ [-Wimplicit-function-declaration] 214 | cleanup_filesystem(&state); | ^~~~~~~~~~~~~~~~~~ ll.c: At top level: ll.c:219:6: warning: conflicting types for ‘show_help’; have ‘void()’ 219 | void show_help() { | ^~~~~~~~~ ll.c:172:5: note: previous implicit declaration of ‘show_help’ with type ‘void()’ 172 | show_help(); | ^~~~~~~~~ ll.c:232:19: error: unknown type name ‘FileNode’ 232 | void remove_child(FileNode* parent, const char* name) { | ^~~~~~~~ 你给出的代码报错,修改bug并给出修改后的完整代码
最新发布
05-28
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值