1

I am writing a bash script and need to cd into a directory, but the directory name is somewhat dynamic. It always begins with package-{then dynamic version}. How do I script this in bash?

cd package-

3 Answers 3

2

I'm not sure I get your requirement fully.

What about cd package-*? If there are several matches, which one would you like to choose?

0

If there is only one such directory in that directory, you could do

cd package-*
0

You could try this, however it would break if you have more than one folder..

#!/bin/bash

find . -type d -name package* -exec cd {} \;
Do something else
1
  • I really doubt you can change dir that way
    – hmontoliu
    May 20, 2011 at 20:24

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .