shellwin10的wsl子系统,删除文件报错-bash: /usr/bin/rm: Argument list too long

Posted 代码诠释的世界

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了shellwin10的wsl子系统,删除文件报错-bash: /usr/bin/rm: Argument list too long相关的知识,希望对你有一定的参考价值。

1、场景

    由于测试需要删除缓存目录相关文件,但是rm -rf ./*的时候报错

 

2、处理方法

cd [需要删除的目录]
ls | xargs -n 10 rm -fr ls

参数解释:

输出所有的文件名(用空格分割) xargs就是将ls的输出,每10个为一组(以空格为分隔符),作为rm -rf的参数也就是说将所有文件名10个为一组,由rm -rf删除

# xargs --help
Usage: xargs [OPTION]... COMMAND [INITIAL-ARGS]...
Run COMMAND with arguments INITIAL-ARGS and more arguments read from input.

Mandatory and optional arguments to long options are also
mandatory or optional for the corresponding short option.
  -0, --null                   items are separated by a null, not whitespace;
                                 disables quote and backslash processing and
                                 logical EOF processing
  -a, --arg-file=FILE          read arguments from FILE, not standard input
  -d, --delimiter=CHARACTER    items in input stream are separated by CHARACTER,
                                 not by whitespace; disables quote and backslash
                                 processing and logical EOF processing
  -E END                       set logical EOF string; if END occurs as a line
                                 of input, the rest of the input is ignored
                                 (ignored if -0 or -d was specified)
  -e, --eof[=END]              equivalent to -E END if END is specified;
                                 otherwise, there is no end-of-file string
  -I R                         same as --replace=R
  -i, --replace[=R]            replace R in INITIAL-ARGS with names read
                                 from standard input; if R is unspecified,
                                 assume 
  -L, --max-lines=MAX-LINES    use at most MAX-LINES non-blank input lines per
                                 command line
  -l[MAX-LINES]                similar to -L but defaults to at most one non-
                                 blank input line if MAX-LINES is not specified
  -n, --max-args=MAX-ARGS      use at most MAX-ARGS arguments per command line
  -o, --open-tty               Reopen stdin as /dev/tty in the child process
                                 before executing the command; useful to run an
                                 interactive application.
  -P, --max-procs=MAX-PROCS    run at most MAX-PROCS processes at a time
  -p, --interactive            prompt before running commands
      --process-slot-var=VAR   set environment variable VAR in child processes
  -r, --no-run-if-empty        if there are no arguments, then do not run COMMAND;
                                 if this option is not given, COMMAND will be
                                 run at least once
  -s, --max-chars=MAX-CHARS    limit length of command line to MAX-CHARS
      --show-limits            show limits on command-line length
  -t, --verbose                print commands before executing them
  -x, --exit                   exit if the size (see -s) is exceeded
      --help                   display this help and exit
      --version                output version information and exit

Please see also the documentation at http://www.gnu.org/software/findutils/.
You can report (and track progress on fixing) bugs in the "xargs"
program via the GNU findutils bug-reporting page at
https://savannah.gnu.org/bugs/?group=findutils or, if
you have no web access, by sending email to <bug-findutils@gnu.org>.

 

3、结果

执行后便可以顺利执行删除动作了

 

 

参考链接:

https://blog.csdn.net/ss810540895/article/details/126698298

 

Windows11 WSL 打开Ubuntu 报错 WslRegisterDistribution failed with error: 0x800701bc

1、背景说明

Windows在不安装虚拟化软件的情况下,如果想安装Linux子系统,可以使用 WSL实现。

WSL (Windows Subsystem for Linux),Windows10以上的版本支持安装 Linux 子系统。

安装 WSL 可以参考微软官方文档:https://learn.microsoft.com/en-us/windows/wsl/install

旧版WSL手动安装,请参考:https://learn.microsoft.com/zh-cn/windows/wsl/install-manual


2、问题现象

在微软商店(Microsoft Store)搜索 Ubuntu,获取并安装。

但是,在打开Ubuntu 的时候,报错“WslRegisterDistribution failed with error: 0x800701bc”


3、解决方案

1)安装完WSL,重启电脑;

2)下载 适用于 x64 计算机的 WSL2 Linux 内核更新包:https://wslstorestorage.blob.core.windows.net/wslblob/wsl_update_x64.msi

安装升级后,重新打开 Ubuntu,即可正常访问,效果如下:


以上是关于shellwin10的wsl子系统,删除文件报错-bash: /usr/bin/rm: Argument list too long的主要内容,如果未能解决你的问题,请参考以下文章

wsl已知问题

安装WSL2时遇到的问题(0x80370102报错)解决

打造Win10下完美Linux体验(WSL2+WindowsTerminal+oh-my-zsh),完整图文教程+解决方案(建议收藏)

Windows10 WSL下 龙芯3A 交叉编译环境搭建

如何重启 Windows 10 子系统(WSL) ubuntu

WSL中使用systemctl报错问题