BASH - newbie question regarding line breaks (I think)
Hi folks.
I'm pretty new to the whole BASH programming and i've come unstuck on something that seems pretty simple. Basicly, im trying to insert a break between lines, as when I run my script, I basicly get a wall of text, and would ideally like to space it out a little more to allow for easier reading. In a nut shell, my current returns are as follows: This is the question I am asking this is echoed response AAAA this is echoed response BBBB this is echoed response CCCC this is echoed response DDDD As you can see, it's a little cluttered, this in an entire script is even worse, so ideally i'd like to have the script produce the results as such: This is the question I am asking this is echoed response AAAA this is echoed response BBBB this is echoed response CCCC this is echoed response DDDD So on an so forth. I've looked at this Sed command, but that seems to run on its own seperate script and im not sure on how to incorperate it as each line break is in a different location. Is there a symbol or something that can be used to physically insert a break? Many thanks. -M |
So the lines are outputted by your script?
If so, just echo an extra newline after you echo each line. |
Since you haven't provided a snippet of your script showing how you output the text, I will presume you are using the echo command. There are two ways you could double space your output. First, echo a blank line.
Code:
echo "this is echoed response AAAA" Code:
echo -e "this is echoed response AAAA \n" |
Quote:
|
My many many thanks, I was looking all through the man pages for something which may be related to 'new line' and completely overlooked echo, as you rightly suggested, turns out that the echo man page described everything you did.
|
Quote:
|
For more powerful printing control, consider using the printf command instead.
Code:
printf "this is echoed response %s\n\n" AAAA BBBB CCCC DDDD I've never come across any really good tutorials on printf in bash, but the documentation for gawk's printf function is very good. Just remember that not everything it says is applicable to bash (bash can't handle floating point numbers, for example). http://www.gnu.org/software/gawk/man...de/Printf.html Edit: I knew I should've checked the bash-hacker's wiki first. :doh: http://wiki.bash-hackers.org/commands/builtin/printf |
pick one:
Code:
echo "Something\n" |
Quote:
Code:
$ echo "Something\n" Code:
echo $'Something\n' |
Yes, you're right, I should have checked before posting, \n doesn't produce newline between "double quotes".
|
when you echo
Code:
echo "something good Code:
echo "something good |
All times are GMT -5. The time now is 02:17 AM. |