Home > Software design >  How to prevent the `| clip` command from appending a newline character?
How to prevent the `| clip` command from appending a newline character?

Time:03-14

In Git Bash, when I run the below command:

echo "foo" | clip

and paste the output into a text editor, I see a new line character has been appended to the output string:

foo
<newline>

How can I prevent it from adding the trailing newline character or trim the same after getting appended?

CodePudding user response:

Directly from echo(1) man page:

     -n     do not output the trailing newline

so just add the -n option to the command: echo -n "foo" | clip.

  • Related