如何在字符串中间使用通配符?重击 [英] How to use wildcard in the middle on the string? bash

查看:53
本文介绍了如何在字符串中间使用通配符?重击的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在编写bash脚本

I am writing a bash script

我的文件如下: file ="$ {nodeID} _00000_19700101010 $ {ts} _udp_filtered.pcap" .是否可以使用任何5位数字代替 00000 ?我考虑过使用

My files are like: file="${nodeID}_00000_19700101010${ts}_udp_filtered.pcap". Is it possible to instead of 00000 use any 5digit number? I thought about using

file ="$ {nodeID} _ * _19700101010 $ {ts} _udp_filtered.pcap"

有时候我有00001,有时是00004,等等.

sometimes I have 00001, sometimes 00004, etc.

推荐答案

类似

 echo "${nodeID}"_[0-9][0-9][0-9][0-9][0-9]_19700101010"${ts}"_udp_filtered.pcap

注意, * [something] 不会用引号引起来,因此上面仅引用了变量.

Note, * and [something] won't expand in quotes, so only the variables are quoted above.

这篇关于如何在字符串中间使用通配符?重击的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆