0

The purpose of this is I'm looking into ways to give a confirmation input in python subprocesses. But rather than asking for an extended list, which I would wonder if it's off-topic, is there a way to search through Linux commands to see which have a confirmation option? A dynamical approach I think could check all installed commands for a -y flag (to start with, at least, not all are confirmation, e.g. grep it is obsolete for -i, ignore case). Is there a way to do this? Or maybe there is already an Ubuntu app that provides info like this.

1 Answer 1

1

One way is to search the man pages installed on the system for -y like so:

man -wK -- "-y"

... that will print the paths to man pages which contain -y in their text and the man pages names are pretty descriptive of their related command/package like:

$ 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

You can omit the -w option like so:

man -K -- "-y"

... to have those man pages opend in the terminal one after another instead ... q for next result and Ctrl+c to terminate search results ... See man man for explaination.

Notice that not all commands might come with man pages or have their man pages installed by default, but most are.

3
  • 1
    I like this idea, but see 2 problems: (1) you're going to get a lot of false hits (for example, it matches a lot of emacs-style C-y, M-C-y edit commands in man bash - which has no actual -y option afaik). Since -K appears to search the raw TROFF file, changing to man -wK -- '\fB\-y' | uniq to match bold -y seems to help a lot (reducing the unique filenames returned from 331 to 88 on my system). (2) even where there is a genuine -y match, it may mean something completely different (ex. in the case of ld, the -y option concerns symbol tracing). Commented Oct 24, 2023 at 12:35
  • 1
    ... man -wK --regex -- '\\fB\\-y\\f[PR]' | uniq (changing back to Previous or Roman right after the -y to exclude longer bold strings) reduces it to 82 hits Commented Oct 24, 2023 at 12:37
  • @steeldriver Yes, you are right it searches the source of the manual and not the rendered text so markup symbols are an upside but other content like comments are a downside … Also a RegEx might be expanded to match e.g. both -y and yes thus reducing false positives … I think
    – Raffa
    Commented Oct 24, 2023 at 13:01

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .