# sh echo ???



## bvgdas (Jan 15, 2022)

`sh -c "echo '111 $USER\n$USER'"`

output:

```
111 root\nroot
```

`\n` - I guess this is new line


----------



## monwarez (Jan 15, 2022)

You will need to tell echo to expand backslash escapes

```
sh -c "echo -e '111 $USER\n$USER'"
```


----------



## bvgdas (Jan 15, 2022)

monwarez said:


> You will need to tell echo to expand backslash escapes
> 
> ```
> sh -c "echo -e '111 $USER\n$USER'"
> ```


yes. you're right. sh(1)


```
echo [-e | -n] [string ...]
             Print a space-separated list of the arguments to the standard
             output and append a newline character.

             -n      Suppress the output of the trailing newline.

             -e      Process C-style backslash escape sequences.
```


----------



## eurohick2 (Jan 19, 2022)

echo (and input to echo from a commandline reader/shell) is shell specific.  you can google up a list of ways "echo" differs in shells.  you'd like to avoid shell coding relying on "behaviors"


----------



## gpw928 (Jan 20, 2022)

If you want wide portability, it's best to avoid the fancy features of echo, but life is too difficult without a universal way to do BSD "echo -n":
	
	



```
# BSD "echo -n"
case `echo -n` in
    -*) Echon() { echo ${1:+"$@"}"\c"; };;
    *)  Echon() { echo -n ${1:+"$@"}; };;
esac
```


----------

