0

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?

  • See https://unix.stackexchange.com/a/321753/135943 which gives the best way to call a command on each file found by find. – Wildcard Jul 10 '17 at 22:58

1 Answers1

1

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.

Wildcard
  • 36,499