cut*_*tjm 6 bash rhel gnome sed tilix
在我故意删除的测试服务器?????
上/
- 我期待删除符号链接/lib64
和/media
目录。一切顺利(一切都失败了),但随后我对下面的输出感到好奇:
[root@testserver /]# ls
bin boot dev etc home lib lib64 media mnt opt proc rh_share3 root run sbin srv sys tmp usr var
[root@testserver /]# rm -rf ?????
bash: /usr/bin/sed: No such file or directory
[root@testserver /]# ls
bash: /usr/bin/ls: No such file or directory
bash: /usr/bin/sed: No such file or directory
Run Code Online (Sandbox Code Playgroud)
我看到某些软件包具有sed
依赖性,但我不明白为什么它需要sed
像按这样简单的东西Enter
[root@testserver bin]# rpm -q --whatrequires sed
krb5-libs-1.17-18.el8.x86_64
ca-certificates-2019.2.32-80.0.el8_1.noarch
dracut-049-70.git20200228.el8.x86_64
crypto-policies-20191128-2.git23e1bf1.el8.noarch
policycoreutils-2.9-9.el8.x86_64
authselect-libs-1.1-2.el8.x86_64
cups-filters-1.20.0-19.el8.x86_64
open-vm-tools-11.0.0-4.el8.x86_64
authselect-compat-1.1-2.el8.x86_64
dhcp-client-4.3.6-40.el8.x86_64
nfs-utils-2.3.3-31.el8.x86_64
autofs-5.1.4-40.el8.x86_64
Run Code Online (Sandbox Code Playgroud)
为什么会出现这条线bash: /usr/bin/sed: No such file or directory
?显然sed
被认为是缺失的,但为什么它会被调用呢?如果我只是运行一个strace -o bash bash
. 我知道sed
代表stream editor
- 每个 bash 命令都运行了sed
,或者还有什么可能发生?
操作系统是带有 GUI 的 OOTB RHEL 8.2 (Oopta)。
编辑
以下是输出set | grep sed
:
[user1@testserver ~]$ set | grep sed
local command=$(HISTTIMEFORMAT= history 1 | sed 's/^ *[0-9]\+ *//');
COMPREPLY=($( compgen -W "$( bpftool help 2>&1 | command sed -e '/OBJECT := /!d' -e 's/.*{//' -e 's/}.*//' -e 's/|//g' )" -- "$cur" ));
COMPREPLY+=($( compgen -W "$( bpftool -jp btf 2>&1 | command sed -n 's/.*"id": \(.*\),$/\1/p' )" -- "$cur" ))
COMPREPLY+=($( compgen -W "$( bpftool -jp map 2>&1 | command sed -n 's/.*"id": \(.*\),$/\1/p' )" -- "$cur" ))
COMPREPLY+=($( compgen -W "$( bpftool -jp map 2>&1 | command grep -C2 "$type" | command sed -n 's/.*"id": \(.*\),$/\1/p' )" -- "$cur" ))
COMPREPLY+=($( compgen -W "$( bpftool -jp prog 2>&1 | command sed -n 's/.*"id": \(.*\),$/\1/p' )" -- "$cur" ))
COMPREPLY+=($( compgen -W "$( bpftool -jp prog 2>&1 | command sed -n 's/.*"tag": "\(.*\)",$/\1/p' )" -- "$cur" ))
type=$(bpftool -jp map show $keyword $ref | command sed -n 's/.*"type": "\(.*\)",$/\1/p');
COMPREPLY=($( compgen -W "$( command sed -ne 's|^iface \([^ ]\{1,\}\).*$|\1|p' /etc/network/interfaces /etc/network/interfaces.d/* 2>/dev/null )" -- "$cur" ));
COMPREPLY=($( compgen -W "$( printf '%s\n' /etc/sysconfig/network/ifcfg-* | command sed -ne 's|.*ifcfg-\([^*].*\)$|\1|p' )" -- "$cur" ));
COMPREPLY=($( compgen -W "$( command ls -B /etc/sysconfig/interfaces | command sed -ne 's|.*ifcfg-\([^*].*\)$|\1|p' )" -- "$cur" ));
COMPREPLY=($( compgen -W "$( printf '%s\n' /etc/sysconfig/network-scripts/ifcfg-* | command sed -ne 's|.*ifcfg-\([^*].*\)$|\1|p' )" -- "$cur" ));
local included=$( command sed -ne 's/^[[:blank:]]*[Ii][Nn][Cc][Ll][Uu][Dd][Ee][[:blank:]]\{1,\}\([^#%]*\)\(#.*\)\{0,1\}$/\1/p' "${configfile}" );
COMPREPLY+=($( compgen -W "$( { LC_ALL=C ifconfig -a || ip addr show; } 2>/dev/null | command sed -ne 's/.*addr:\([^[:space:]]*\).*/\1/p' -ne 's|.*inet[[:space:]]\{1,\}\([^[:space:]/]*\).*|\1|p' )" -- "$cur" ))
[[ $# -ge $OPTIND ]] && echo "error: $FUNCNAME("$@"): unprocessed arguments:" $(while [[ $# -ge $OPTIND ]]; do printf '%s\n' ${!OPTIND}; shift; done);
local hosts=$( command sed -ne 's/^[[:blank:]]*[Hh][Oo][Ss][Tt][[:blank:]]\{1,\}\([^#*?%]*\)\(#.*\)\{0,1\}$/\1/p' "${config[@]}" );
local argtype=$( LC_ALL=C $1 --help 2>&1 | command sed -ne "s|.*$prev\[\{0,1\}=[<[]\{0,1\}\([-A-Za-z0-9_]\{1,\}\).*|\1|p" );
COMPREPLY=($( compgen -W "$( LC_ALL=C $1 --help 2>&1 | command sed -ne 's/.*\(--[-A-Za-z0-9]\{1,\}=\{0,1\}\).*/\1/p' | sort -u )" -- "$cur" ));
COMPREPLY+=($( { LC_ALL=C ifconfig -a || ip link show; } 2>/dev/null | command sed -ne "s/.*[[:space:]]HWaddr[[:space:]]\{1,\}\($re\)[[:space:]].*/\1/p" -ne "s/.*[[:space:]]HWaddr[[:space:]]\{1,\}\($re\)[[:space:]]*$/\1/p" -ne "s|.*[[:space:]]\(link/\)\{0,1\}ether[[:space:]]\{1,\}\($re\)[[:space:]].*|\2|p" -ne "s|.*[[:space:]]\(link/\)\{0,1\}ether[[:space:]]\{1,\}\($re\)[[:space:]]*$|\2|p"
COMPREPLY+=($( { arp -an || ip neigh show; } 2>/dev/null | command sed -ne "s/.*[[:space:]]\($re\)[[:space:]].*/\1/p" -ne "s/.*[[:space:]]\($re\)[[:space:]]*$/\1/p" ));
COMPREPLY+=($( command sed -ne "s/^[[:space:]]*\($re\)[[:space:]].*/\1/p" /etc/ethers 2>/dev/null ));
COMPREPLY=($( compgen -W "$( command ls -RL $modpath 2>/dev/null | command sed -ne 's/^\(.*\)\.k\{0,1\}o\(\.[gx]z\)\{0,1\}$/\1/p' )" -- "$cur" ))
COMPREPLY=($( compgen -X '<defunct>' -W '$( command ps axo comm | command sed -e 1d )' -- "$cur" ));
COMPREPLY=($( compgen -X '<defunct>' -W '$( command ps axo command= | command sed -e \
COMPREPLY=($( compgen -W '`command sed -e "y/|/ /" \
COMPREPLY+=($( compgen -W "$( command sed -ne 's/^\([^[:space:]#|]\{2,\}\)|.*/\1/p' /etc/termcap 2>/dev/null )" -- "$cur" ));
Run Code Online (Sandbox Code Playgroud)
我认为问题是你已经重写了command
, 一个内置函数:
$ help command | head --lines=2
command: command [-pVv] command [arg ...]
Execute a simple command or display information about commands.
Run Code Online (Sandbox Code Playgroud)
command
通常用于忽略别名和函数以直接显式运行内置或可执行文件。这对于避免无限循环很有用。例如:
ls() {
command ls --color=auto
}
Run Code Online (Sandbox Code Playgroud)
这会调用ls
可执行文件,而不是永远递归地调用自身。
unset command
并在您的 Bash 配置文件中查找 的任何用途command
。