Using multiple wildcards in path to run command on all files in directory
Clash Royale CLAN TAG#URR8PPP
up vote
0
down vote
favorite
I'm trying to run a for loop that copies all files in a directory and then place them in a backup directory. There are multiple sub-directories with varying names so I thought I should use multiple wildcards so I didn't have to list all of them out and add another for loop in. This is my script
#!/bin/bash
DIR="/home/users/data/*"
for file in $DIR
do
cp "$file"/**/**/*.txt* "$DIR"/backup/"$file"
done
When I run it though the script can't go into the sub directories and thinks the directory is
/directory1/**/**/*.txt*
Any advice would be greatly appreciated
bash wildcards
add a comment |Â
up vote
0
down vote
favorite
I'm trying to run a for loop that copies all files in a directory and then place them in a backup directory. There are multiple sub-directories with varying names so I thought I should use multiple wildcards so I didn't have to list all of them out and add another for loop in. This is my script
#!/bin/bash
DIR="/home/users/data/*"
for file in $DIR
do
cp "$file"/**/**/*.txt* "$DIR"/backup/"$file"
done
When I run it though the script can't go into the sub directories and thinks the directory is
/directory1/**/**/*.txt*
Any advice would be greatly appreciated
bash wildcards
add a comment |Â
up vote
0
down vote
favorite
up vote
0
down vote
favorite
I'm trying to run a for loop that copies all files in a directory and then place them in a backup directory. There are multiple sub-directories with varying names so I thought I should use multiple wildcards so I didn't have to list all of them out and add another for loop in. This is my script
#!/bin/bash
DIR="/home/users/data/*"
for file in $DIR
do
cp "$file"/**/**/*.txt* "$DIR"/backup/"$file"
done
When I run it though the script can't go into the sub directories and thinks the directory is
/directory1/**/**/*.txt*
Any advice would be greatly appreciated
bash wildcards
I'm trying to run a for loop that copies all files in a directory and then place them in a backup directory. There are multiple sub-directories with varying names so I thought I should use multiple wildcards so I didn't have to list all of them out and add another for loop in. This is my script
#!/bin/bash
DIR="/home/users/data/*"
for file in $DIR
do
cp "$file"/**/**/*.txt* "$DIR"/backup/"$file"
done
When I run it though the script can't go into the sub directories and thinks the directory is
/directory1/**/**/*.txt*
Any advice would be greatly appreciated
bash wildcards
bash wildcards
asked 5 mins ago
M76
1
1
add a comment |Â
add a comment |Â
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f474958%2fusing-multiple-wildcards-in-path-to-run-command-on-all-files-in-directory%23new-answer', 'question_page');
);
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password