LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 10-19-2010, 12:00 PM   #1
paliga
Member
 
Registered: Feb 2010
Posts: 39

Rep: Reputation: 0
how to echo an '-n' without a new line?


thanks in advance...
 
Old 10-19-2010, 12:01 PM   #2
Tinkster
Moderator
 
Registered: Apr 2002
Location: earth
Distribution: slackware by choice, others too :} ... android.
Posts: 23,067
Blog Entries: 11

Rep: Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928
Code:
echo -n "-n"
?

Not that I understand you question, really.
 
Old 10-19-2010, 12:07 PM   #3
GrapefruiTgirl
LQ Guru
 
Registered: Dec 2006
Location: underground
Distribution: Slackware64
Posts: 7,594

Rep: Reputation: 556Reputation: 556Reputation: 556Reputation: 556Reputation: 556Reputation: 556
Tink, that's what I thought too; didn't work. OP, if it doesn't work for you, try this:

echo -ne "-\x6e"
 
Old 10-19-2010, 12:17 PM   #4
Tinkster
Moderator
 
Registered: Apr 2002
Location: earth
Distribution: slackware by choice, others too :} ... android.
Posts: 23,067
Blog Entries: 11

Rep: Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928
Heh
Interesting ... never actually TRIED it. Must be a bug
in the tools parsing.


Cheers,
Tink
 
Old 10-19-2010, 12:39 PM   #5
forrestt
Senior Member
 
Registered: Mar 2004
Location: Cary, NC, USA
Distribution: Fedora, Kubuntu, RedHat, CentOS, SuSe
Posts: 1,288

Rep: Reputation: 99
This should work:

Code:
/bin/echo -n -e '\055'n
HTH

Forrest
 
Old 10-19-2010, 07:03 PM   #6
grail
LQ Guru
 
Registered: Sep 2009
Location: Perth
Distribution: Manjaro
Posts: 10,007

Rep: Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191
Is there a reason we don't just escape it like we would any other special item?
Code:
echo -n '\-n'
Single or double quotes both work.
 
Old 10-19-2010, 07:08 PM   #7
GrapefruiTgirl
LQ Guru
 
Registered: Dec 2006
Location: underground
Distribution: Slackware64
Posts: 7,594

Rep: Reputation: 556Reputation: 556Reputation: 556Reputation: 556Reputation: 556Reputation: 556
Quote:
Originally Posted by grail View Post
Is there a reason we don't just escape it like we would any other special item?
Code:
echo -n '\-n'
Single or double quotes both work.
Doesn't work here:
Code:
root@reactor: echo -n '\-n'
\-nroot@reactor: 
root@reactor: 
root@reactor: echo -n "\-n"
\-nroot@reactor: 
root@reactor:
Does it actually work for you grail?
 
Old 10-20-2010, 05:21 AM   #8
paliga
Member
 
Registered: Feb 2010
Posts: 39

Original Poster
Rep: Reputation: 0
Code:
geek@lazy:~$ echo -ne "-\x6e"
-ngeek@lazy:~$ 
geek@lazy:~$  echo -ne "\055"n
-ngeek@lazy:~$
This is exactly what I wanted and expected.
Thank you : )
 
Old 10-20-2010, 07:44 AM   #9
grail
LQ Guru
 
Registered: Sep 2009
Location: Perth
Distribution: Manjaro
Posts: 10,007

Rep: Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191
@GGirl - my bad ... completely missed the \ was still being printed Ignore me I am used to it ... lol
 
  


Reply



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 Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Echo every other line yitzle Linux - Software 19 08-03-2010 10:36 AM
how to remove new line in bash using echo packets Programming 9 11-24-2009 09:00 PM
Delaying Echo mid-line Romanus81 Programming 8 06-12-2008 05:27 PM
echo on a new line does not work B-Boy Linux - Newbie 2 06-02-2008 09:54 AM
How to echo variables and commands in one line? hindll01 Programming 1 09-10-2004 06:02 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 03:28 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