📄 basename.1
字号:
.\" SCCSID: @(#)basename.1 8.2 12/5/90.TH basename 1.SH Namebasename \- strip directory names from pathname.SH Syntax.B basename.I string[.I suffix].SH Description.NX R "basename command".NX R "file name" "stripping affixes"The.PN basenamecommanddeletes from .I stringany prefix up to and including the last slash.BR ( / )and the suffix (if specified), and prints the result on the standardoutput. The.PN basenamecommand handles limited regular expressions in the same manner as.MS ed 1 ;metacharacters must be escaped if they are intended to be interpretedliterally. For example:.EX% \f(CBbasename /vmunix .x\f(CWvmun% \f(CBbasename /vmunix '\e.x'\f(CWvmunix.EEIn the first example,.PN basenamereturns.PN vmunbecause it interprets the.PN \&.xas a regular expression consisting of any character followed by theletter.PN x .In the second example, the dot is escaped; there is no match on a dotfollowed by.PN x ,and.PN basenamereturns.PN vmunix ..PPThe.PN basenamecommand is often used inside substitution marks.BR ( \`\ \` )within shell procedures..SH ExamplesThe following example shell script compiles the file.PN /usr/src/bin/cat.cand moves the output to.PN catin the current directory:.EXcc /usr/src/bin/cat.cmv a.out \`basename $1 .c\`.EEThe following example echoes only the base name of the file.PN /etc/syslog.confby removing the prefix and any possible sequence of charactersfollowing the period in the file's name:.EX% \f(CBbasename /etc/syslog.conf '\e..*'\f(CWsyslog.EE.SH See Alsodirname(1), ex(1), sh(1)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -