0
#!/bin/bash
list=$(find $1 -not -empty -type f -printf "%s\n" | sort -rn | uniq -d | xargs -I{} -n1 find -type f -size {}c -print0 | xargs -0 md5sum | sort | uniq -w32 --all-repeated=separate)
echo $list

It finds files with the same content and sorts them. If I run this in terminal just like that it prints nicely, but when I run this in script

printf "%s\n"

it doesn't work and it looks ugly, how can I fix that? I'm new to this bash scripting, it's probably super easy.

choroba
  • 231,213
  • 25
  • 204
  • 289
Shadov
  • 5,421
  • 2
  • 19
  • 38
  • What do you mean by "ugly"? Try `echo "$list"` (echo with quotes). – ks1322 Nov 14 '15 at 15:19
  • Wow it worked, like I said, super easy. Thank you very much. – Shadov Nov 14 '15 at 15:22
  • 1
    Unless you are doing something else with `list`, there is no reason to capture the output of the pipeline just to use it with `echo`. Just use `find ... | sort ...| ...` – chepner Nov 14 '15 at 15:32

0 Answers0