I have no idea what I should do to make it work:

find . -name '*.txt' -printf '\t%s\t%f\n' |sort -n -r | > txt.txt

This should work

find . -name '*.txt' -printf '\t%s\t%f\n' | sort -n -r > txt.txt

You have to remove the | at the end, > means redirect the stdout(standard output) to a file.

If there is an error that text will be displayed in the stderr. Which is the standard output for all errors.

If you want to redirect that to a file: 2> /path/to/a/file

Due note that there is a difference between > and >>.

  • > Will overwrite the entire file's content
  • >> Will append at the end of the file's content

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.