LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
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 02-11-2003, 04:45 PM   #1
eallen
LQ Newbie
 
Registered: Jan 2002
Distribution: Suse Linux 7.3 - 8.1
Posts: 22

Rep: Reputation: 15
echo command peculiarity


Why is the following happening?

mis254@mis254:~> JUNK="/home/mis254/r?belcher"
mis254@mis254:~> echo $JUNK
/home/mis254/r belcher
mis254@mis254:~> JUNK="/home/mis254/r?belchers"
mis254@mis254:~> echo $JUNK
/home/mis254/r?belchers

The first case JUNK is a path to a real file on my system called...
/home/mis254/r belcher
when I echo out JUNK, it will not echo the '?' character
The second case JUNK is not a path to a real file.
when I echo out JUNK this time, it will echo the '?' character.

It appears the echo command is determining my string of chars to
be an actual file. Is this normal?
 
Old 02-11-2003, 04:53 PM   #2
chrisk5527
Member
 
Registered: Oct 2002
Location: Michigan
Distribution: Slackware Linux 10.0
Posts: 289

Rep: Reputation: 30
Does this problem happening continually or was it just a fluke?
 
Old 02-11-2003, 05:04 PM   #3
MasterC
LQ Guru
 
Registered: Mar 2002
Location: Salt Lake City, UT - USA
Distribution: Gentoo ; LFS ; Kubuntu ; CentOS ; Raspbian
Posts: 12,613

Rep: Reputation: 69
Here is my confusion on this:

You echoed an actual directory, meaning:
/home/mis254/r belcher exists. Then you tried to echo a non-existent file/directory:
/home/mis254/r?belchers

So I am guessing Linux saw the actual directory there, and echoed the correct thing, however it couldn't find the actual directory/file to echo for the second, so it returned exactly what you requested?

... I've got no idea in other words

Cool
 
Old 02-11-2003, 05:30 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
Re: echo command peculiarity

Quote:
Originally posted by eallen
Why is the following happening?

mis254@mis254:~> JUNK="/home/mis254/r?belcher"
mis254@mis254:~> echo $JUNK
/home/mis254/r belcher
mis254@mis254:~> JUNK="/home/mis254/r?belchers"
mis254@mis254:~> echo $JUNK
/home/mis254/r?belchers

The first case JUNK is a path to a real file on my system called...
/home/mis254/r belcher
when I echo out JUNK, it will not echo the '?' character
The second case JUNK is not a path to a real file.
when I echo out JUNK this time, it will echo the '?' character.

It appears the echo command is determining my string of chars to
be an actual file. Is this normal?
Not sure what shell/echo you are using,
but in bash it's *not* normal, and it doesn't work that
way, either ;) ... Since anything you put in $JUNK
is just a string of characters it shouldn't (and in
GNU bash, version 2.05a.0(1) doesn't) matter whether
it happens to be a file's name or not :)

Must be a peculiarity of whatever shell/echo
you are using ;)


Cheers,
Tink
 
  


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



Similar Threads
Thread Thread Starter Forum Replies Last Post
Bash Script, no new line for echo command jorisb Linux - General 5 11-05-2005 12:08 AM
echo command to a running process happy78 Programming 18 09-06-2005 01:03 PM
Bash Scripting - echo command question gbhil Programming 2 04-27-2005 07:27 PM
what is the echo command in perl? hamish Programming 5 12-14-2004 08:31 AM
CGI script problem: Send/Expect command echo on webpage rajatgarg Programming 2 07-11-2004 04:38 PM

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

All times are GMT -5. The time now is 10:46 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
Open Source Consulting | Domain Registration