LinuxQuestions.org
Review your favorite Linux distribution.
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: in a fallen world
Distribution: slackware by choice, others too :} ... android.
Posts: 23,067
Blog Entries: 11

Rep: Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910
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: 551Reputation: 551Reputation: 551Reputation: 551Reputation: 551Reputation: 551
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: in a fallen world
Distribution: slackware by choice, others too :} ... android.
Posts: 23,067
Blog Entries: 11

Rep: Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910
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: 9,493

Rep: Reputation: 2867Reputation: 2867Reputation: 2867Reputation: 2867Reputation: 2867Reputation: 2867Reputation: 2867Reputation: 2867Reputation: 2867Reputation: 2867Reputation: 2867
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: 551Reputation: 551Reputation: 551Reputation: 551Reputation: 551Reputation: 551
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: 9,493

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


Reply


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 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


All times are GMT -5. The time now is 01:12 AM.

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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration