dextract is a tool which convert files. The normal usage is dextract -q test.h5 > test.fastq. How is it possible to combine it with find command e.g. find All_RawData/Each_Cell_Raw/ -name "*.bax.h5" | xargs -I {} dextract -q {} > How to get the file name after > from find command with fastq extension rather h5 extension?


Like so:

find All_RawData/Each_Cell_Raw -name '*.bax.h5' -exec sh -c 'for f do dextract -q "$f" > "${f%.h5}.fastq"; done' find-sh {} +

With some line breaks for easier reading:

find All_RawData/Each_Cell_Raw -name '*.bax.h5' -exec sh -c '
  for f
    do dextract -q "$f" > "${f%.h5}.fastq"
  done' find-sh {} +

For explanation and rationale, see https://unix.stackexchange.com/a/321753/135943.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.