[英]Unix wildcard expansion/ regular expression
What will the below command do? 以下命令会做什么?
ls -l ${INPUT%.jnl}.jnl
$INPUT
consists of some value. $INPUT
由一些值组成。
${INPUT%.jnl}
strips the shortest match of .jnl
from the back of $INPUT
. ${INPUT%.jnl}
从$INPUT
的后面剥离最短的.jnl
匹配项。
By then saying ${INPUT%.jnl}.jnl
it looks like a way to make $INPUT
consist in something + .jnl
and prevent it being two times .jnl
at the end, if $INPUT
already contained that value. 然后说${INPUT%.jnl}.jnl
似乎是一种使$INPUT
包含某物+ .jnl
的方法,如果$INPUT
已经包含该值,则防止它最后是.jnl
。
So ls -l ${INPUT%.jnl}.jnl
will perform a ls -l
in the path/name indicated by $INPUT
, making sure it ends with .jnl
. 所以ls -l ${INPUT%.jnl}.jnl
将在$INPUT
指示的路径/名称中执行ls -l
,并确保其以.jnl
。
See some tests regarding the ${INPUT%.jnl}
expression: 查看有关${INPUT%.jnl}
表达式的一些测试:
$ var="hello.jnl.jnlbye"
$ echo ${var%.jnl}
hello.jnl.jnlbye # as .jnl is not present in the back, nothing gets removed
$ var="hello.jnl.jnl"
$ echo ${var%.jnl}
hello.jnl # it removed the last .jnl
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.