0

I have this line

echo "Total artists: "$(find /users/foo/bar/movies 
-maxdepth 2 -mindepth 2 -type d
| awk -F / '{print $NF}'|sort|uniq -d)

I want this to print new line as part of the results. So far I have tried

echo "Total artists: "$(find /users/foo/bar/movies 
-maxdepth 2 -mindepth 2 -type d
| awk -F / '{print $NF;print "\n"}'|sort|uniq -d)

and a couple other suggestions on SO. Putting

echo " " 

doesn't work either on the terminal

Mykel
  • 119
  • 1
  • 9
  • Possible duplicate of [How to avoid bash command substitution to remove the newline character?](https://stackoverflow.com/questions/15184358/how-to-avoid-bash-command-substitution-to-remove-the-newline-character) – muru Oct 04 '18 at 05:12
  • Just `echo` prints a newline. It's not clear how the current output is wrong; probably you should avoid the command substitution as suggested by the duplicate nomination, or else quote it. See also https://stackoverflow.com/questions/10067266/when-to-wrap-quotes-around-a-shell-variable – tripleee Oct 04 '18 at 05:14
  • If your problem can be reduced to `echo " " doesn't produce a newline` then just say **that**. All the rest of your question is irrelevant if that is happening. – Ed Morton Oct 04 '18 at 14:27

1 Answers1

0

Have you tried

printf "%s\n", $NF

I'm not sure I understand the question, but that seems like the logical answer from my perspective.

It may also be that you are asking for a terminal NL, not every time. If that is the question, you could do

{print $NF} END {print}

I suspect I am totally missing something.

MJB
  • 7,639
  • 2
  • 31
  • 41