Mee*_*org 3 bash scripts alias functions bashrc
从这篇文章https://askubuntu.com/a/266839/75967看到一个命令,我想别名
find {,/usr}/{,s}bin -printf '%f\0' | xargs -0 whatis | sort | less
Run Code Online (Sandbox Code Playgroud)
我假设 the lessor the|有干扰,但如何让 alias 命令忽略导致它出现问题的那些字符?
IE。这不起作用
alias cccc='find {,/usr}/{,s}bin -printf '%f\0' | xargs -0 whatis | sort | less'
cccc
Run Code Online (Sandbox Code Playgroud)
它返回
pell0modem-manager0airserv-ng0usermod0vipw0filefrag0update-software-center0ntpdate-
debian0usbmuxd0foomatic-extract-text0cupsenable0dpkg-divert0dpkg-preconfigure0foomatic-
getpjloptions0ldattach0hplj10200bccmd0vpnc-disconnect0madwifi-
unload0cupsd0tcpd0hplj10180pppstats0service0update-icon-caches0atieventsd0hpljP15050grub-
set-default0userdel0arpd0gpsdctl0remove-shell0cpgr0winbindd0cracklib-format0update-catalog0wesside-ng0vmware-authdlauncher0aireplay-ng0install-docs0hciattach0lpc0install-menu0ck-log-system-restart0foomatic-printermap-to-gutenprint-xml0setvesablank0gconf-schemas0airmon-ng0zic0update-apt-xapian-index0pm-suspend0rebuild-
Run Code Online (Sandbox Code Playgroud)
代替
[ (1) - check file types and compare values
2to3 (1) - Python2 to Python3 converter
2to3-2.7 (1) - Python2 to Python3 converter
2to3-3.2 (1) - Python2 to Python3 converter
411toppm (1) - convert Sony Mavica .411 image to ppm
7z (1) - A file archiver with highest compression ratio
7za (1) - A file archiver with highest compression ratio
a2p (1) - Awk to Perl translator
accept (2) - accept a connection on a socket
accessdb (8) - dumps the content of a man-db database in a human read...
aclocal-1.11 (1) - manual page for aclocal 1.11.6
aclocal (1) - manual page for aclocal 1.11.3
Run Code Online (Sandbox Code Playgroud)
当你自己执行命令时。
Run Code Online (Sandbox Code Playgroud)After the Fact - Supplemental
我还为自己添加了另一个有用的函数,用于通过字符串查询该命令目录。
fff() {
find {,/usr}/{,s}bin -printf '%f\0' | xargs -0 whatis |& grep $1
}
Run Code Online (Sandbox Code Playgroud)
因此,如果您键入该命令fff pdf,它将向您显示有关 pdf 的所有相关命令,如下所示
pdfunite (1) - Portable Document Format (PDF) page merger
ps2pdf13 (1) - Convert PostScript to PDF 1.3 (Acrobat 4-and-later com...
pdftotext (1) - Portable Document Format (PDF) to text converter (vers...
ps2pdfwr (1) - Convert PostScript to PDF without specifying Compatibi...
pdfdetach (1) - Portable Document Format (PDF) document embedded file ...
ps2pdf (1) - Convert PostScript to PDF using ghostscript
ps2pdf12 (1) - Convert PostScript to PDF 1.2 (Acrobat 3-and-later com...
pdf2dsc (1) - generate a PostScript page list of a PDF document
pdfimages (1) - Portable Document Format (PDF) image extractor (versio...
pdftoppm (1) - Portable Document Format (PDF) to Portable Pixmap (PPM...
foomatic-ppdfile (1) - Generate a PPD file for a given printer/driver combo
dvipdf (1) - Convert TeX DVI file to PDF using ghostscript and dvips
qpdf (1) - PDF transformation software
pdftocairo (1) - Portable Document Format (PDF) to PNG/JPEG/PDF/PS/EPS/...
pdfseparate (1) - Portable Document Format (PDF) page extractor
pdftops (1) - Portable Document Format (PDF) to PostScript converter...
ps2pdf14 (1) - Convert PostScript to PDF 1.4 (Acrobat 5-and-later com...
pdfinfo (1) - Portable Document Format (PDF) document information ex...
pdftohtml (1) - program to convert PDF files into HTML, XML and PNG im...
pdfopt (1) - Ghostscript PDF Optimizer
pdffonts (1) - Portable Document Format (PDF) font analyzer (version ...
pdf2ps (1) - Ghostscript PDF to PostScript translator
Run Code Online (Sandbox Code Playgroud)
我认为这对于了解所有可用的命令很有用
不要为更复杂的东西使用别名,而是使用 shell 函数:
function cccc() {
find {,/usr}/{,s}bin -printf '%f\0' | xargs -0 whatis | sort | less
}
Run Code Online (Sandbox Code Playgroud)
请参阅man bash理由:
有关别名的定义和使用的规则有些令人困惑。在执行该行上的任何命令之前,Bash 总是至少读取一行完整的输入。别名在读取命令时展开,而不是在执行时展开。因此,与另一个命令出现在同一行上的别名定义在读取下一行输入之前不会生效。该行别名定义后面的命令不受新别名的影响。执行函数时,此行为也是一个问题。别名在读取函数定义时展开,而不是在执行函数时展开,因为函数定义本身就是一个复合命令。因此,函数中定义的别名在执行该函数之前不可用。为了安全起见,
| 归档时间: |
|
| 查看次数: |
412 次 |
| 最近记录: |