1

I'm trying to use mkdir command in a bash script using a "*" wildcard. Full code is: mkdir -p $EXTRACTDIR/$CV_NAME*/release

It supposed to create a folder "release" in an existing "OpenCV-2.2.0" folder. Two computers does exactly that and the third creates a folder OpenCV*/release, and I can't figure out why.

Thnx for your help

0

2 Answers 2

3

The find command is a very useful command indeed, especially when using the -exec option. I whole heartedly recommend reading up on it further.

find ./$EXTRACTDIR -type d -name $CV_NAME\* -exec mkdir {}/release \; 

{} translates the result of the search into the mkdir comand. the parents option for mkdir ( -p ) is not needed because the folder must exist in order to be found.

Sign up to request clarification or add additional context in comments.

Comments

2

On the third computer "OpenCV-2.2.0/release" doesn't exist, so wildcard matching will fail and will result in a string where * is untouched.

cd $EXTRACTDIR/$CV_NAME*; mkdir release

or

mkdir `echo $EXTRACTDIR/$CV_NAME*`/release 

if you have multiple $CV_NAME* directories, you have to use a loop.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.