简体   繁体   English

BASH更好的方式回顾一下?

[英]BASH better way to do a look back?

hey guys I'm wondering if there is a smart way to look back before a period in bash 嘿伙计们,我想知道是否有一种聪明的方式可以在bash期间回顾一下

file='foo'/bar/styles.css?ver=1.4.2

ext=$(echo ${file} | gawk -F  "?" '{print$1}')
echo "${ext##*.}" # css

Seems like I should be able to do this all in my expansion somehow? 似乎我应该能够以某种方式在我的扩展中完成所有这些工作?

Don't think you can do it with just one bash expansion statement (unless they can be nested somehow), works fine with two though 不要以为只用一个bash扩展语句就可以做到(除非它们可以以某种方式嵌套),但是两个工作正常

$ start=${file%%\?*}; echo ${start##*.}
css

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM