2

Is there a way to remove the automatically added '\n' when using string redirection:

$ <<< 'abc' wc -c
4

Of course I'm looking for short solutions (things like <<< 'abc' tr -d '\n' | wc -c aren't interesting).

zeralight
  • 620
  • 1
  • 5
  • 19
  • 1
    The [bash manual](https://www.gnu.org/software/bash/manual/html_node/Redirections.html#Here-Strings) says about that: `The result is supplied as a single string, with a newline appended`. I guess it's not possible to omit the newline. – hek2mgl Nov 19 '18 at 12:28
  • 2
    A here string is syntactic sugar for a single-line here document. If you don't want to work with a line (in the [POSIX sense](https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap03.html#tag_03_206)), don't use here strings. – chepner Nov 19 '18 at 13:40
  • 2
    Is `echo -n 'abc' | wc -c` short enough to be interesting? – ottomeister Nov 19 '18 at 20:48

0 Answers0