|
|||||||
| Forums | Search Forums | Register | Forum Rules | Man Pages | Albums | FAQ | Members | Calendar | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here. |
|
|
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
new line in echo
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. |
| Sponsored Links | ||
|
|
#2
|
|||
|
|||
|
You can enter a new line like this. Code:
echo "\n" |
| Sponsored Links | ||
|
|
#3
|
|||
|
|||
|
Code:
echo "X1 02:12:13\nX2 03:02:12" Regards |
|
#4
|
|||
|
|||
|
Actually, not all versions of echo permit backslash escape codes, but all versions of the shell should allow newlines inside quoted strings. Code:
echo "X1 02:12:13 X2 03:02:12" Yup, that's a newline smack dab in the middle of the quoted string. |
| Sponsored Links | |
|
|
#5
|
|||
|
|||
|
Pass the -e parameter to enable interpretation of backslash escapes(which us off by default). Like this:
PHP Code:
|
| Sponsored Links | |
|
|
#6
|
||||
|
||||
|
Quote:
The simplest and most portable way is to use printf: Code:
string="12 34\n56 78" printf "%b\n" "$string" |
| Sponsored Links | ||
|
![]() |
| Thread Tools | Search this Thread |
| Display Modes | |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| echo two command output in the same line | chuikingman | Shell Programming and Scripting | 4 | 01-25-2011 01:38 AM |
| Echo and a command's output on the same line | codyhazelwood | Shell Programming and Scripting | 7 | 03-23-2010 07:24 PM |
| echo and new line | melanie_pfefer | UNIX for Advanced & Expert Users | 6 | 12-11-2008 01:55 PM |
| echo just 1 line before execution/set +-x | fabulous2 | Shell Programming and Scripting | 3 | 12-19-2007 01:52 AM |
| how to echo the file contents LINE BY LINE | newbie168 | Shell Programming and Scripting | 4 | 02-22-2006 05:43 AM |
|
|