LinuxQuestions.org
Visit Jeremy's Blog.
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 08-24-2010, 10:09 AM   #1
SentralOrigin
Member
 
Registered: Jul 2005
Distribution: Gentoo, Ubuntu
Posts: 318

Rep: Reputation: 30
Question about why a command does this


Code:
$ echo 2 * 3 > 5 is a valid inequality.
This will create a file in the current directory named '5' with the number '2' in it, the names of all the files in the current directory, followed by the number '3' and 'is a valid inequality.'

What I do not understand is why 'is a valid inequality' gets written to this file. I thought it would write '2', all the file names in the current directory, then '3' into the file called '5'. Why does the 'is a valid inequality.' get written to the file also?
 
Old 08-24-2010, 10:13 AM   #2
GrapefruiTgirl
LQ Guru
 
Registered: Dec 2006
Location: underground
Distribution: Slackware64
Posts: 7,594

Rep: Reputation: 551Reputation: 551Reputation: 551Reputation: 551Reputation: 551Reputation: 551
Hmm.. What shell are you using, and what version? Not sure if it matters, but thought I'd ask, since for me, the command works as you would expect it to, I think:
Code:
root@reactor: echo 2 * 3 > 5
root@reactor: cat 5
2 crap crappo.tex 3
root@reactor:
 
Old 08-24-2010, 10:19 AM   #3
SentralOrigin
Member
 
Registered: Jul 2005
Distribution: Gentoo, Ubuntu
Posts: 318

Original Poster
Rep: Reputation: 30
bash 3.2.something I think (it says bash 3.2 when I do $SHELL but I remember seeing a bunch of other numbers somewhere else)

Code:
$ echo 2 * 3 > 5 is a valid inequality.
$
$ cat 5
2 somefolder somefiles 3 is a valid inequality.
$
 
Old 08-24-2010, 10:38 AM   #4
grail
LQ Guru
 
Registered: Sep 2009
Location: Perth
Distribution: Manjaro
Posts: 9,564

Rep: Reputation: 2901Reputation: 2901Reputation: 2901Reputation: 2901Reputation: 2901Reputation: 2901Reputation: 2901Reputation: 2901Reputation: 2901Reputation: 2901Reputation: 2901
yes i get the same results as you OP. Here is something else to prove the point:
Code:
 echo > 7 one two * three
This will create the file '7' with strings 'one', 'two', contents of current directory and 'three' inside it.
Echo is treating all fields presented to it individually, as there are no quotes. The moment it finds the redirection it knows that it should send all data
it finds to that location. As it then finds more strings on the line it then processes those and acts accordingly.
 
1 members found this post helpful.
  


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
du command question mokku Linux - Newbie 4 07-16-2008 10:48 AM
command question satimis Debian 2 07-27-2006 04:41 PM
Question About a Command? carlosinfl Linux - General 4 10-28-2005 01:51 PM
Command question satimis Fedora 2 04-15-2005 07:52 PM
who command question Malique Linux - Newbie 2 03-22-2004 03:18 AM

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

All times are GMT -5. The time now is 12:05 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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration