Skip to main content
formatting; tags; grammar
Source Link
chaos
  • 49.3k
  • 11
  • 127
  • 147

inIn my main_dirmain_dir, I have a lot of sub-folders say DFT1-> DFT150DFT1 to DFT150, and in each directory, there is a file named OSZICAR..OSZICAR. However, some of this would have file size 0..

So I would like to have a script, that goes into each folder and checks the size of OSZICAROSZICAR, if it is below size of 10 bytes... Then, then delete its DFTDFT folder...

The pseudo-code (which doesn't work), I have is:

for f in *; do
 cd $f
 status=(check whether OZICAR has size below 10bytes)
 cd ..
 if (status); do
  rm -r $f
 fi 
done

Could anyone help? Thank you

in my main_dir, I have a lot of sub-folders say DFT1-> DFT150, and in each directory, there is a file named OSZICAR... However, some of this would have file size 0..

So I would like to have a script, that goes into each folder and checks the size of OSZICAR, if it is below size of 10 bytes... Then delete its DFT folder...

The pseudo-code (which doesn't work), I have is:

for f in *; do
 cd $f
 status=(check whether OZICAR has size below 10bytes)
 cd ..
 if (status); do
  rm -r $f
 fi 
done

Could anyone help? Thank you

In my main_dir, I have a lot of sub-folders say DFT1 to DFT150, and in each directory, there is a file named OSZICAR. However, some of this would have file size 0.

So I would like to have a script, that goes into each folder and checks the size of OSZICAR, if it is below size of 10 bytes, then delete its DFT folder.

The pseudo-code (which doesn't work), I have is:

for f in *; do
 cd $f
 status=(check whether OZICAR has size below 10bytes)
 cd ..
 if (status); do
  rm -r $f
 fi 
done
Source Link
user40780
  • 2k
  • 4
  • 16
  • 16

Detecting file size and do operation conditionally

in my main_dir, I have a lot of sub-folders say DFT1-> DFT150, and in each directory, there is a file named OSZICAR... However, some of this would have file size 0..

So I would like to have a script, that goes into each folder and checks the size of OSZICAR, if it is below size of 10 bytes... Then delete its DFT folder...

The pseudo-code (which doesn't work), I have is:

for f in *; do
 cd $f
 status=(check whether OZICAR has size below 10bytes)
 cd ..
 if (status); do
  rm -r $f
 fi 
done

Could anyone help? Thank you