nameis=$(basename $dataset .csv)
但是我想先删除任何扩展名,而不知道它是否知道如何做?@H_301_4@
任何帮助赞赏,
摊晒@H_301_4@
nameis=${dataset%.*}
…例如:@H_301_4@
$ dataset=foo.txt $ nameis=${dataset%.*} $ echo $nameis foo
这种语法在bash手册页中描述为:@H_301_4@
${parameter%word}@H_301_4@
${parameter%%word}@H_301_4@
Remove matching suffix pattern. The word is expanded to produce a pattern just as in pathname expansion. If the pattern matches a trailing portion of the expanded value of parameter,then the result of the expansion is the expanded value of parameter with the shortest matching pattern (the “%” case) or the longest matching pattern (the “%%” case) deleted. If parameter is @ or *,the pattern removal operation is applied to each positional parameter in turn,and the expansion is the resultant list. If parameter is an array variable subscripted with @ or *,the pattern removal operation is applied to each member of the array in turn,and the expansion is the resultant list.@H_301_4@