Matching all files ending with a certain extension with a shell glob (say, all files ending with .sh)
Clash Royale CLAN TAG#URR8PPP
up vote
1
down vote
favorite
I desire to match all files ending with a certain extension with a shell glob.
In this case I desire to target all files ending with the .sh
extension, which are bourne files I execute with the Bash shell after putting a "shebang" (like #!/bin/bash
) at their first line.
This is, for example, a cron command I have:
0 0 * * * "$HOME"/public_html/cron_daily/myfile.sh 2>/dev/null
Instead myfile.sh I need to target all files in that dir, ending with a .sh
extension.
Is the following code correct?
0 0 * * * "$HOME"/public_html/cron_daily/*$.sh 2>/dev/null
Update
I think this is good when using a glob:
*.sh
shell-script wildcards
add a comment |Â
up vote
1
down vote
favorite
I desire to match all files ending with a certain extension with a shell glob.
In this case I desire to target all files ending with the .sh
extension, which are bourne files I execute with the Bash shell after putting a "shebang" (like #!/bin/bash
) at their first line.
This is, for example, a cron command I have:
0 0 * * * "$HOME"/public_html/cron_daily/myfile.sh 2>/dev/null
Instead myfile.sh I need to target all files in that dir, ending with a .sh
extension.
Is the following code correct?
0 0 * * * "$HOME"/public_html/cron_daily/*$.sh 2>/dev/null
Update
I think this is good when using a glob:
*.sh
shell-script wildcards
I thought âÂÂYouâÂÂd just use*.sh
to match all files with a.sh
extension.â was clear enough...*.sh
is the glob you use to match files ending with.sh
.
â Stephen Kitt
Jul 11 at 21:03
add a comment |Â
up vote
1
down vote
favorite
up vote
1
down vote
favorite
I desire to match all files ending with a certain extension with a shell glob.
In this case I desire to target all files ending with the .sh
extension, which are bourne files I execute with the Bash shell after putting a "shebang" (like #!/bin/bash
) at their first line.
This is, for example, a cron command I have:
0 0 * * * "$HOME"/public_html/cron_daily/myfile.sh 2>/dev/null
Instead myfile.sh I need to target all files in that dir, ending with a .sh
extension.
Is the following code correct?
0 0 * * * "$HOME"/public_html/cron_daily/*$.sh 2>/dev/null
Update
I think this is good when using a glob:
*.sh
shell-script wildcards
I desire to match all files ending with a certain extension with a shell glob.
In this case I desire to target all files ending with the .sh
extension, which are bourne files I execute with the Bash shell after putting a "shebang" (like #!/bin/bash
) at their first line.
This is, for example, a cron command I have:
0 0 * * * "$HOME"/public_html/cron_daily/myfile.sh 2>/dev/null
Instead myfile.sh I need to target all files in that dir, ending with a .sh
extension.
Is the following code correct?
0 0 * * * "$HOME"/public_html/cron_daily/*$.sh 2>/dev/null
Update
I think this is good when using a glob:
*.sh
shell-script wildcards
edited Jul 11 at 19:57
asked Jul 11 at 17:38
user9303970
116223
116223
I thought âÂÂYouâÂÂd just use*.sh
to match all files with a.sh
extension.â was clear enough...*.sh
is the glob you use to match files ending with.sh
.
â Stephen Kitt
Jul 11 at 21:03
add a comment |Â
I thought âÂÂYouâÂÂd just use*.sh
to match all files with a.sh
extension.â was clear enough...*.sh
is the glob you use to match files ending with.sh
.
â Stephen Kitt
Jul 11 at 21:03
I thought âÂÂYouâÂÂd just use
*.sh
to match all files with a .sh
extension.â was clear enough... *.sh
is the glob you use to match files ending with .sh
.â Stephen Kitt
Jul 11 at 21:03
I thought âÂÂYouâÂÂd just use
*.sh
to match all files with a .sh
extension.â was clear enough... *.sh
is the glob you use to match files ending with .sh
.â Stephen Kitt
Jul 11 at 21:03
add a comment |Â
2 Answers
2
active
oldest
votes
up vote
1
down vote
accepted
You can't do it that way, since they will be combined into one command line.
for scr in "$HOME"/public_html/cron_daily/*.sh ; do "$scr" 2> /dev/null; done
I believe it isn't a great deal but writingfile
insteadscr
could be clearer and more accurate as it is a file containing a script. What do you think?
â user9303970
Jul 14 at 23:02
add a comment |Â
up vote
4
down vote
YouâÂÂd just use *.sh
to match all files with a .sh
extension. (Adding the path as appropriate.)
However this wonâÂÂt have the result youâÂÂre after. Look at run-parts
to run multiple scripts from cron
:
0 0 * * * /usr/bin/run-parts "$HOME"/public_html/cron_daily/ 2>/dev/null
(This will run all executables in .../public_html/cron_daily
, not just .sh
files. By the way, are you sure itâÂÂs a good idea to keep cron scripts under public_html
? Is that directory being served by your web server?)
I think only website directories are served from that directory but maybe not.
â user9303970
Jul 11 at 17:45
add a comment |Â
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
1
down vote
accepted
You can't do it that way, since they will be combined into one command line.
for scr in "$HOME"/public_html/cron_daily/*.sh ; do "$scr" 2> /dev/null; done
I believe it isn't a great deal but writingfile
insteadscr
could be clearer and more accurate as it is a file containing a script. What do you think?
â user9303970
Jul 14 at 23:02
add a comment |Â
up vote
1
down vote
accepted
You can't do it that way, since they will be combined into one command line.
for scr in "$HOME"/public_html/cron_daily/*.sh ; do "$scr" 2> /dev/null; done
I believe it isn't a great deal but writingfile
insteadscr
could be clearer and more accurate as it is a file containing a script. What do you think?
â user9303970
Jul 14 at 23:02
add a comment |Â
up vote
1
down vote
accepted
up vote
1
down vote
accepted
You can't do it that way, since they will be combined into one command line.
for scr in "$HOME"/public_html/cron_daily/*.sh ; do "$scr" 2> /dev/null; done
You can't do it that way, since they will be combined into one command line.
for scr in "$HOME"/public_html/cron_daily/*.sh ; do "$scr" 2> /dev/null; done
answered Jul 11 at 17:40
Ignacio Vazquez-Abrams
31.9k66680
31.9k66680
I believe it isn't a great deal but writingfile
insteadscr
could be clearer and more accurate as it is a file containing a script. What do you think?
â user9303970
Jul 14 at 23:02
add a comment |Â
I believe it isn't a great deal but writingfile
insteadscr
could be clearer and more accurate as it is a file containing a script. What do you think?
â user9303970
Jul 14 at 23:02
I believe it isn't a great deal but writing
file
instead scr
could be clearer and more accurate as it is a file containing a script. What do you think?â user9303970
Jul 14 at 23:02
I believe it isn't a great deal but writing
file
instead scr
could be clearer and more accurate as it is a file containing a script. What do you think?â user9303970
Jul 14 at 23:02
add a comment |Â
up vote
4
down vote
YouâÂÂd just use *.sh
to match all files with a .sh
extension. (Adding the path as appropriate.)
However this wonâÂÂt have the result youâÂÂre after. Look at run-parts
to run multiple scripts from cron
:
0 0 * * * /usr/bin/run-parts "$HOME"/public_html/cron_daily/ 2>/dev/null
(This will run all executables in .../public_html/cron_daily
, not just .sh
files. By the way, are you sure itâÂÂs a good idea to keep cron scripts under public_html
? Is that directory being served by your web server?)
I think only website directories are served from that directory but maybe not.
â user9303970
Jul 11 at 17:45
add a comment |Â
up vote
4
down vote
YouâÂÂd just use *.sh
to match all files with a .sh
extension. (Adding the path as appropriate.)
However this wonâÂÂt have the result youâÂÂre after. Look at run-parts
to run multiple scripts from cron
:
0 0 * * * /usr/bin/run-parts "$HOME"/public_html/cron_daily/ 2>/dev/null
(This will run all executables in .../public_html/cron_daily
, not just .sh
files. By the way, are you sure itâÂÂs a good idea to keep cron scripts under public_html
? Is that directory being served by your web server?)
I think only website directories are served from that directory but maybe not.
â user9303970
Jul 11 at 17:45
add a comment |Â
up vote
4
down vote
up vote
4
down vote
YouâÂÂd just use *.sh
to match all files with a .sh
extension. (Adding the path as appropriate.)
However this wonâÂÂt have the result youâÂÂre after. Look at run-parts
to run multiple scripts from cron
:
0 0 * * * /usr/bin/run-parts "$HOME"/public_html/cron_daily/ 2>/dev/null
(This will run all executables in .../public_html/cron_daily
, not just .sh
files. By the way, are you sure itâÂÂs a good idea to keep cron scripts under public_html
? Is that directory being served by your web server?)
YouâÂÂd just use *.sh
to match all files with a .sh
extension. (Adding the path as appropriate.)
However this wonâÂÂt have the result youâÂÂre after. Look at run-parts
to run multiple scripts from cron
:
0 0 * * * /usr/bin/run-parts "$HOME"/public_html/cron_daily/ 2>/dev/null
(This will run all executables in .../public_html/cron_daily
, not just .sh
files. By the way, are you sure itâÂÂs a good idea to keep cron scripts under public_html
? Is that directory being served by your web server?)
answered Jul 11 at 17:39
Stephen Kitt
139k22296359
139k22296359
I think only website directories are served from that directory but maybe not.
â user9303970
Jul 11 at 17:45
add a comment |Â
I think only website directories are served from that directory but maybe not.
â user9303970
Jul 11 at 17:45
I think only website directories are served from that directory but maybe not.
â user9303970
Jul 11 at 17:45
I think only website directories are served from that directory but maybe not.
â user9303970
Jul 11 at 17:45
add a comment |Â
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%2f454749%2fmatching-all-files-ending-with-a-certain-extension-with-a-shell-glob-say-all-f%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
I thought âÂÂYouâÂÂd just use
*.sh
to match all files with a.sh
extension.â was clear enough...*.sh
is the glob you use to match files ending with.sh
.â Stephen Kitt
Jul 11 at 21:03