Hi
i would like disply the new line in echo command.
i have input like:
echo " X1 02:12:13 X2 03:02:12 "
out put:
X1 02:12:13
X2 03:02:12
can you tell how can use new line option in echo command.
Hi
i would like disply the new line in echo command.
i have input like:
echo " X1 02:12:13 X2 03:02:12 "
out put:
X1 02:12:13
X2 03:02:12
can you tell how can use new line option in echo command.
You can enter a new line like this.
echo "\n"
echo "X1 02:12:13\nX2 03:02:12"
Regards
Actually, not all versions of echo permit backslash escape codes, but all versions of the shell should allow newlines inside quoted strings.
echo "X1 02:12:13
X2 03:02:12"
Yup, that's a newline smack dab in the middle of the quoted string.
Pass the -e parameter to enable interpretation of backslash escapes(which us off by default). Like this:
echo -e "hello\nworld!"
Jostein Topland
The -e option is not standard. A POSIX-compliant echo does not accept any options:
$ echo -e "12 34\n56 78"
-e 12 34\n56 78
The simplest and most portable way is to use printf:
string="12 34\n56 78"
printf "%b\n" "$string"