LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 09-04-2014, 07:36 AM   #1
qwerewq
LQ Newbie
 
Registered: Mar 2010
Location: Lithuania, Vilnius, Pasilai
Distribution: Debian (testing)
Posts: 27

Rep: Reputation: 0
Question how to make new line in echo


hi team,

Sorry for spamming this board with a silly question.

I want to get a single line command and, let's say, "single command" script for gathering info about server and forming output to dokuwiki.

I have a command, but echo do not print new line, to make dokuwiki human readable code, I need it to output a new line in an output where specified \n.
Here is my line:
Code:
echo "====== `hostname` ====== \n ===== Description ===== \n ===== OS ===== \n <code>`uname -a ; cat /etc/redhat-release`</code> \n ===== Net ===== \n ==== ip a s ==== \n <code>`/sbin/ip a s`</code> \n ==== ip r s ==== \n <code>`/sbin/ip r s`</code> \n ==== netstat -tanupl or -tanul ==== \n <code>`if [[ $EUID -eq 0 ]]; then netstat -tanupl ; else netstat -tanul ; fi`</code> \n </code>"
I know, that I can do something like:
Code:
echo "====== `hostname` ======
===== Description =====
===== OS =====
<code>`uname -a ; cat /etc/redhat-release`</code>
===== Net =====
==== ip a s ====
<code>`/sbin/ip a s`</code>
==== ip r s ====
<code>`/sbin/ip r s`</code>
==== netstat -tanupl ====
<code>`if [[ $EUID -eq 0 ]]; then netstat -tanupl ; else netstat -tanul ; fi`</code>"
But I want it to have in a single line, to make it brilliant .

Thankyou for your help.

And as advantage, would be additional info which I can get I also thought about dmidecode... but not sure if it will be useful...

Thank you again for reading it till the end!!! Woohoo!

edited, command, added if, but I think it's not working.
edited 2, if issue fixed.
edited 3, Correct answer:
Code:
echo -e "====== `hostname` ====== \n ===== Description ===== \n ===== OS ===== \n <code>`uname -a ; cat /etc/redhat-release`</code> \n ===== Net ===== \n ==== ip a s ==== \n <code>`/sbin/ip a s`</code> \n ==== ip r s ==== \n <code>`/sbin/ip r s`</code> \n ==== netstat `if [[ $EUID -eq 0 ]]; then echo '-tanupl' ; esle echo '-tanul' ; fi` ==== \n <code>`if [[ $EUID -eq 0 ]]; then netstat -tanupl ; else netstat -tanul ; fi`</code>"

Last edited by qwerewq; 09-04-2014 at 08:01 AM. Reason: fixing main post. to be uptodate.
 
Old 09-04-2014, 07:49 AM   #2
syg00
LQ Veteran
 
Registered: Aug 2003
Location: Australia
Distribution: Lots ...
Posts: 21,315

Rep: Reputation: 4172Reputation: 4172Reputation: 4172Reputation: 4172Reputation: 4172Reputation: 4172Reputation: 4172Reputation: 4172Reputation: 4172Reputation: 4172Reputation: 4172
As is usual, reading the manpage is a good start.
 
1 members found this post helpful.
Old 09-04-2014, 07:52 AM   #3
qwerewq
LQ Newbie
 
Registered: Mar 2010
Location: Lithuania, Vilnius, Pasilai
Distribution: Debian (testing)
Posts: 27

Original Poster
Rep: Reputation: 0
fixed if issue:
From:
Code:
if [[ $((id -u)) -eq "0" ]]
To:
Code:
if [[ $EUID -eq 0 ]]
So if issue fixed, new line issue still persists.
 
  


Reply

Tags
bash, dokuwiki, echo, script, scripting


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] Bash ECHO new line tkinsella Linux - Newbie 3 02-03-2014 02:41 PM
[SOLVED] How can i echo at same line with TCL DoME69 Programming 7 11-19-2011 04:51 AM
[SOLVED] how to echo an '-n' without a new line? paliga Linux - Newbie 8 10-20-2010 08:44 AM
Echo every other line yitzle Linux - Software 19 08-03-2010 11:36 AM
echo on a new line does not work B-Boy Linux - Newbie 2 06-02-2008 10:54 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 02:56 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration