Skip to main content
Question Protected by dr_
edited tags
Link
Gilles 'SO- stop being evil'
  • 865.4k
  • 205
  • 1.8k
  • 2.3k
bash is not central to the question
Source Link
Jeff Schaller
  • 68.8k
  • 35
  • 122
  • 265

Test if there are files matching a pattern in bashorder to execute a script

I am trying to write an ifif statement in bash to test whether there are any files matching a certain pattern. If there is a text file in a directory it should run a given script.

My code currently:

if [ -f /*.txt ]; then ./script fi

Please give some ideasideas; I only want to run the script if there is a .txt in the directory.

Test if there are files matching a pattern in bash

I am trying to write an if statement in bash to test whether there are any files matching a certain pattern. If there is a text file in a directory it should run a given script.

My code currently

if [ -f /*.txt ]; then ./script fi

Please give some ideas I only want to run the script if there is a .txt in the directory.

Test if there are files matching a pattern in order to execute a script

I am trying to write an if statement to test whether there are any files matching a certain pattern. If there is a text file in a directory it should run a given script.

My code currently:

if [ -f /*.txt ]; then ./script fi

Please give some ideas; I only want to run the script if there is a .txt in the directory.

edited tags
Source Link
Gilles 'SO- stop being evil'
  • 865.4k
  • 205
  • 1.8k
  • 2.3k

Test if condition to runthere are files matching a scriptpattern in bash

I am trying to write an if statement in bash to test whether there are any files matching a certain pattern.

  If there is a text file in a directory it should run a given script.

My code currently

if [ -f /*.txt ]; then ./script fi

Please give some ideas I only want to run the script if there is a .txt in the directory.

if condition to run a script in bash

I am trying to write an if statement in bash.

  If there is a text file in a directory it should run a given script

My code currently

if [ -f /*.txt ]; then ./script fi

Please give some ideas I only want to run the script if there is a .txt in the directory.

Test if there are files matching a pattern in bash

I am trying to write an if statement in bash to test whether there are any files matching a certain pattern. If there is a text file in a directory it should run a given script.

My code currently

if [ -f /*.txt ]; then ./script fi

Please give some ideas I only want to run the script if there is a .txt in the directory.

added 14 characters in body
Source Link
Anthon
  • 81.4k
  • 42
  • 174
  • 228
Loading
Source Link
user40952
  • 477
  • 1
  • 5
  • 5
Loading