Question

I defined $A that has the value A12 (for example ). how do I pass that value to the location that has XXX in the command :

ls -dtr XXX_[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9] | sort -n | tail -1

the XXX_[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9] is actually a folder name format (a12_20130233)

is there a way to pass it?

Was it helpful?

Solution

Normally it would be as simple as $A but because the following character (an underscore in this case) can be interpreted as part of the variable name, it needs to be delimited with {}, like so:

ls -dtr ${A}_[0-9]...
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top