I have a directory of FASTA files, some of which are empty (placeholders that were output from a pipeline) and I would like to delete the empty files using a for loop on the command line.
From what I have seen so far I can use the wc -l [file]
approach to see "if there are lines present, delete the file" but I want to make sure the syntax is right before deleting important files. I was thinking it might be easier for the command to look for the " > " symbol found at the header in FASTA files and if it's not present delete the file.
Here is what I have so far:
for file in *.fasta; do "if wc -l < 1 rm file"; done
Or
for file in *.fasta; do "grep > | rm file"; done
find
command, as the answer from @Ram RS shows. But on a separate note, neither of the above commands are syntactically correct. For a safe way to use these commands & test them, substitutels
forrm
, to simply list files rather than delete them. $\endgroup$find
with-links
and let me know $\endgroup$find
implementations have the-empty
or-delete
flags. $\endgroup$