有没有办法找出哪些命令有确认选项?

有没有办法找出哪些命令有确认选项?

这样做的目的是,我正在研究在 python 子进程中提供确认输入的方法。但是,与其要求提供扩展列表(我想知道这是否偏离主题),有没有办法搜索 Linux 命令以查看哪些命令具有确认选项?我认为动态方法可以检查所有已安装的命令是否有标志-y(首先,至少并非所有命令都是确认,例如,grep它已过时-i,忽略大小写)。有办法做到这一点吗?或者可能已经有一个提供此类信息的 Ubuntu 应用程序。

答案1

一种方法是搜索系统上安装的手册页,如下所示-y

man -wK -- "-y"

...这将打印包含在其文本中的手册页的路径-y,并且手册页名称非常描述其相关的命令/包,例如:

$ man -wK -- "-y"
/usr/share/man/man1/ffmpeg-devices.1.gz
/usr/share/man/man1/ffmpeg-formats.1.gz
/usr/share/man/man1/ffmpeg-protocols.1.gz
/usr/share/man/man1/ffmpeg-utils.1.gz
/usr/share/man/man1/ffmpeg.1.gz
/usr/share/man/man1/ffplay.1.gz
/usr/share/man/man1/bash.1.gz
/usr/share/man/man1/rsync.1.gz
/usr/share/man/man1/pamdeinterlace.1.gz
/usr/share/man/man1/pamstretch.1.gz
/usr/share/man/man1/pamstretch.1.gz
/usr/share/man/man1/pbmtoppa.1.gz
/usr/share/man/man1/pgmcrater.1.gz
/usr/share/man/man1/pnmcomp.1.gz
/usr/share/man/man1/pnmscale.1.gz
/usr/share/man/man1/pnmtotiff.1.gz
/usr/share/man/man1/ppmcie.1.gz
/usr/share/man/man1/ppmforge.1.gz
/usr/share/man/man1/ppmlabel.1.gz
/usr/share/man/man1/ppmshadow.1.gz
/usr/share/man/man1/ppmtompeg.1.gz
/usr/share/man/man1/ppmtopcx.1.gz
/usr/share/man/man1/ppmtopj.1.gz
/usr/share/man/man1/pstopnm.1.gz
/usr/share/man/man1/sldtoppm.1.gz
/usr/share/man/man1/tifftopnm.1.gz
/usr/share/man/man1/gprof.1.gz
/usr/share/man/man1/gprof.1.gz
/usr/share/man/man1/ld.bfd.1.gz
/usr/share/man/man1/ld.bfd.1.gz
/usr/share/man/man1/ld.bfd.1.gz
/usr/share/man/man1/ld.bfd.1.gz
/usr/share/man/man1/ld.gold.1.gz
/usr/share/man/man1/ld.gold.1.gz
/usr/share/man/man1/ld.gold.1.gz
/usr/share/man/man1/ld.gold.1.gz
/usr/share/man/man1/yad.1.gz
/usr/share/man/man1/vim.1.gz
/usr/share/man/man1/vim.1.gz
/usr/share/man/man1/vim.1.gz
/usr/share/man/man1/vim.1.gz
/usr/share/man/man1/vim.1.gz
/usr/share/man/man1/vim.1.gz
/usr/share/man/man1/flatpak-install.1.gz
/usr/share/man/man1/flatpak-uninstall.1.gz
/usr/share/man/man1/flatpak-update.1.gz
/usr/share/man/man1/ubuntu-advantage.1.gz
/usr/share/man/man1/ubuntu-advantage.1.gz
/usr/share/man/man1/ubuntu-advantage.1.gz
/usr/share/man/man1/dot.1.gz
/usr/share/man/man1/dot.1.gz
/usr/share/man/man1/dot.1.gz
/usr/share/man/man1/dot.1.gz
/usr/share/man/man1/dot.1.gz
/usr/share/man/man1/dot.1.gz
/usr/share/man/man1/screen.1.gz
/usr/share/man/man1/x86_64-linux-gnu-g++-11.1.gz
/usr/share/man/man1/x86_64-linux-gnu-g++-11.1.gz
/usr/share/man/man1/x86_64-linux-gnu-g++-11.1.gz
/usr/share/man/man1/x86_64-linux-gnu-g++-11.1.gz
/usr/share/man/man1/x86_64-linux-gnu-g++-11.1.gz
/usr/share/man/man1/cacafire.1.gz
/usr/share/man/man1/cacafire.1.gz
/usr/share/man/man1/img2txt.1.gz
/usr/share/man/man1/x86_64-linux-gnu-gcc-11.1.gz
/usr/share/man/man1/x86_64-linux-gnu-gcc-11.1.gz
/usr/share/man/man1/x86_64-linux-gnu-gcc-11.1.gz
/usr/share/man/man1/x86_64-linux-gnu-gcc-11.1.gz
/usr/share/man/man1/x86_64-linux-gnu-gcc-11.1.gz
/usr/share/man/man1/add-apt-repository.1.gz
/usr/share/man/man1/add-apt-repository.1.gz
/usr/share/man/man1/alsaloop.1.gz
/usr/share/man/man1/apg.1.gz
/usr/share/man/man1/bitmap.1.gz
/usr/share/man/man1/bitmap.1.gz
/usr/share/man/man1/bitmap.1.gz
/usr/share/man/man1/brltty.1.gz
/usr/share/man/man1/busybox.1.gz
/usr/share/man/man1/debconf-apt-progress.1.gz
/usr/share/man/man1/debian-distro-info.1.gz
/usr/share/man/man1/diff.1.gz
/usr/share/man/man1/distro-info.1.gz
/usr/share/man/man1/dpkg.1.gz
/usr/share/man/man1/duplicity.1.gz
/usr/share/man/man1/fc-cache.1.gz
/usr/share/man/man1/gpg.1.gz
/usr/share/man/man1/grep.1.gz
/usr/share/man/man1/grep.1.gz
/usr/share/man/man1/grep.1.gz
/usr/share/man/man1/grep.1.gz
/usr/share/man/man1/grog.1.gz
/usr/share/man/man1/grub-mkimage.1.gz
/usr/share/man/man1/grub-mkstandalone.1.gz
/usr/share/man/man1/hostname.1.gz
/usr/share/man/man1/hostname.1.gz
/usr/share/man/man1/hostname.1.gz
/usr/share/man/man1/hostname.1.gz
/usr/share/man/man1/hostname.1.gz
/usr/share/man/man1/hp-firmware.1.gz
/usr/share/man/man1/killall.1.gz
/usr/share/man/man1/l2test.1.gz
/usr/share/man/man1/less.1.gz
/usr/share/man/man1/less.1.gz
/usr/share/man/man1/lscpu.1.gz
/usr/share/man/man1/memusage.1.gz
/usr/share/man/man1/memusagestat.1.gz
/usr/share/man/man1/nano.1.gz
/usr/share/man/man1/nano.1.gz
/usr/share/man/man1/nano.1.gz
/usr/share/man/man1/nmcli.1.gz
/usr/share/man/man1/orca.1.gz
/usr/share/man/man1/patch.1.gz
/usr/share/man/man1/pdftocairo.1.gz
/usr/share/man/man1/pdftoppm.1.gz
/usr/share/man/man1/pdftotext.1.gz
/usr/share/man/man1/perlbug.1.gz
/usr/share/man/man1/perlbug.1.gz
/usr/share/man/man1/pkcon.1.gz
/usr/share/man/man1/pnm2ppa.1.gz
/usr/share/man/man1/prlimit.1.gz
/usr/share/man/man1/procps.1.gz
/usr/share/man/man1/ps.1.gz
/usr/share/man/man1/scanimage.1.gz
/usr/share/man/man1/spd-say.1.gz
/usr/share/man/man1/strace.1.gz
/usr/share/man/man1/ubuntu-distro-info.1.gz
/usr/share/man/man1/unzip.1.gz
/usr/share/man/man1/whiptail.1.gz
/usr/share/man/man1/xedit.1.gz
/usr/share/man/man1/xrandr.1.gz
/usr/share/man/man1/zenity.1.gz
/usr/share/man/man1/zip.1.gz
/usr/share/man/man1/mpv.1.gz
/usr/share/man/man1/tilda.1.gz
/usr/share/man/man1/dig.1.gz
/usr/share/man/man1/jp2a.1.gz
/usr/share/man/man1/ldapadd.1.gz
/usr/share/man/man1/ldapcompare.1.gz
/usr/share/man/man1/ldapdelete.1.gz
/usr/share/man/man1/ldapexop.1.gz
/usr/share/man/man1/ldapmodify.1.gz
/usr/share/man/man1/ldapmodrdn.1.gz
/usr/share/man/man1/ldappasswd.1.gz
/usr/share/man/man1/ldapsearch.1.gz
/usr/share/man/man1/ldapwhoami.1.gz
/usr/share/man/man1/smbcacls.1.gz
/usr/share/man/man1/inxi.1.gz
/usr/share/man/man1/rtmpdump.1.gz
/usr/share/man/man1/onboard.1.gz
/usr/share/man/man1/nsupdate.1.gz
/usr/share/man/man1/bogofilter.1.gz
/usr/share/man/man1/bogofilter.1.gz
/usr/share/man/man1/bogoutil.1.gz
/usr/share/man/man1/bogoutil.1.gz
/usr/share/man/man1/7zr.1.gz
/usr/share/man/man1/7z.1.gz
/usr/share/man/man1/7za.1.gz
/usr/share/man/man1/neofetch.1.gz
/usr/share/man/man1/picom.1.gz
/usr/share/man/man1/youtube-dl.1.gz
/usr/share/man/man1/ffmpeg-all.1.gz
/usr/share/man/man1/ffplay-all.1.gz
/usr/share/man/man1/ffprobe-all.1.gz
/usr/share/man/man1/ffmpeg-filters.1.gz
/usr/share/man/man8/netplan-info.8.gz
/usr/share/man/man8/cryptsetup.8.gz
/usr/share/man/man8/isadump.8.gz
/usr/share/man/man8/isaset.8.gz
/usr/share/man/man8/dmsetup.8.gz
/usr/share/man/man8/dnsmasq.8.gz
/usr/share/man/man8/e2fsck.8.gz
/usr/share/man/man8/e2fsck.8.gz
/usr/share/man/man8/e2fsck.8.gz
/usr/share/man/man8/e2fsck.8.gz
/usr/share/man/man8/efibootmgr.8.gz
/usr/share/man/man8/fsck.cramfs.8.gz
/usr/share/man/man8/fsck.fat.8.gz
/usr/share/man/man8/fsck.fat.8.gz
/usr/share/man/man8/fsck.fat.8.gz
/usr/share/man/man8/fsck.fat.8.gz
/usr/share/man/man8/hdparm.8.gz
/usr/share/man/man8/mke2fs.8.gz
/usr/share/man/man8/mke2fs.8.gz
/usr/share/man/man8/mke2fs.8.gz
/usr/share/man/man8/mke2fs.8.gz
/usr/share/man/man8/mtr.8.gz
/usr/share/man/man8/nft.8.gz
/usr/share/man/man8/nft.8.gz
/usr/share/man/man8/pam_unix.8.gz
/usr/share/man/man8/sfdisk.8.gz
/usr/share/man/man8/tcpdump.8.gz
/usr/share/man/man8/net.8.gz
/usr/share/man/man8/rtmpgw.8.gz
/usr/share/man/man8/apt-get.8.gz
/usr/share/man/man8/udevadm.8.gz
/usr/share/man/man3/Syntax::Keyword::Try.3pm.gz
/usr/share/man/man3/getpass.3.gz
/usr/share/man/man3/printf.3.gz
/usr/share/man/man3/printf.3.gz
/usr/share/man/man3/printf.3.gz
/usr/share/man/man3/printf.3.gz
/usr/share/man/man3/printf.3.gz
/usr/share/man/man3/printf.3.gz
/usr/share/man/man3/printf.3.gz
/usr/share/man/man3/printf.3.gz
/usr/share/man/man3/printf.3.gz
/usr/share/man/man3/printf.3.gz
/usr/share/man/man3/strftime.3.gz
/usr/share/man/man3/termios.3.gz
/usr/share/man/man3/termios.3.gz
/usr/share/man/man3/termios.3.gz
/usr/share/man/man3/termios.3.gz
/usr/share/man/man3/termios.3.gz
/usr/share/man/man3/termios.3.gz
/usr/share/man/man3/termios.3.gz
/usr/share/man/man3/termios.3.gz
/usr/share/man/man3/termios.3.gz
/usr/share/man/man3/termios.3.gz
/usr/share/man/man3/termios.3.gz
/usr/share/man/man3/termios.3.gz
/usr/share/man/man3/termios.3.gz
/usr/share/man/man3/IO::Stringy.3pm.gz
/usr/share/man/man3/readline.3readline.gz
/usr/share/man/man3/Syntax::Keyword::Try.3pm.gz
/usr/share/man/man3/IO::Stringy.3pm.gz
/usr/share/man/man5/crypttab.5.gz
/usr/share/man/man5/e2fsck.conf.5.gz
/usr/share/man/man5/hosts_options.5.gz
/usr/share/man/man5/nanorc.5.gz
/usr/share/man/man5/sane-bh.5.gz
/usr/share/man/man5/sane-canon_dr.5.gz
/usr/share/man/man5/sane-canon_lide70.5.gz
/usr/share/man/man5/sane-epjitsu.5.gz
/usr/share/man/man5/sane-epson.5.gz
/usr/share/man/man5/sane-epson2.5.gz
/usr/share/man/man5/sane-epsonds.5.gz
/usr/share/man/man5/sane-fujitsu.5.gz
/usr/share/man/man5/sane-hp5590.5.gz
/usr/share/man/man5/sane-kodak.5.gz
/usr/share/man/man5/sane-leo.5.gz
/usr/share/man/man5/sane-matsushita.5.gz
/usr/share/man/man5/sane-microtek2.5.gz
/usr/share/man/man5/sane-sceptre.5.gz
/usr/share/man/man5/sane-sharp.5.gz
/usr/share/man/man5/sane-teco1.5.gz
/usr/share/man/man5/sane-teco2.5.gz
/usr/share/man/man5/sane-teco3.5.gz
/usr/share/man/man5/sane-test.5.gz
/usr/share/man/man5/apt.conf.5.gz
/usr/share/man/man5/crypt.5.gz
/usr/share/man/man5/gimprc-2.10.5.gz
/usr/share/man/man5/gimprc-2.10.5.gz
/usr/share/man/man7/X.7.gz
/usr/share/man/man7/editline.7edit.gz
/usr/share/man/man7/glob.7.gz
/usr/share/man/man7/systemd.directives.7.gz

您可以-w像这样省略该选项:

man -K -- "-y"

... 在终端中一个接一个地打开这些手册页 ...q获取下一个结果并Ctrl+c终止搜索结果 ... 请参阅man man以供解释。

注意并非所有命令都附带手册页或默认安装其手册页,但大多数命令都附带。

相关内容