Apparently mysterious output?


Results 1 to 6 of 6

Thread: Apparently mysterious output?

  1. #1
    Join Date
    Mar 2003
    Location
    UK
    Posts
    621

    Apparently mysterious output?

    Got this puzzling error, well it bloody puzzles me:

    echo $(echo "$(cat file1)/$(cat file2)"|bc) > tee f3

    Trying ineptly to use the command tee. Instead got a file called 'tee' and it was not empty it had: '4 f3' in it. Well I'm mystified???????? The 4 was the result of file1/file2 (file1 has 2 in it, file2 has 0.5 in it) but what's the f3 doing there????????
    MI6, Offensive Information, Hackers, Encryption, UFO, AOL, Infowar, Bubba, benelux, Ufologico Nazionale, domestic disruption, 15kg, DUVDEVAN, debugging, Bluebird, Ionosphere, Keyhole, NABS, Kilderkin, Artichoke, Badger, spookwords, EuroFed, SP4, Crypto AG a few, alleged, Echelon keywords. Please add some to your email signature. Full list: http://www.serendipity.li/cia/bz1.html
    http://www.nosoftwarepatents.com/

  2. #2
    Join Date
    Sep 1999
    Location
    Cambridge, UK
    Posts
    509
    The command as written
    Code:
    echo $(echo "$(cat file1)/$(cat file2)"|bc) > tee f3
    expands to this
    Code:
    echo $(echo "2/0.5"|bc) > tee f3
    which expands to this
    Code:
    echo 4 > tee f3
    which is equivalent to this
    Code:
    echo 4 f3 > tee
    and that wouldn't surpise you at all.

  3. #3
    Join Date
    Jul 2003
    Location
    Spokane, Washington
    Posts
    580
    I love commutative operations.

  4. #4
    Join Date
    Mar 2003
    Location
    UK
    Posts
    621
    Quote Originally Posted by furrycat View Post
    Code:
    echo 4 > tee f3
    which is equivalent to this
    Code:
    echo 4 f3 > tee
    and that wouldn't surpise you at all.
    I'm afraid it would. Understand echo 4 f3 > tee gives tee containing 4 f3, but how is the first code snippet equivalent to this?
    MI6, Offensive Information, Hackers, Encryption, UFO, AOL, Infowar, Bubba, benelux, Ufologico Nazionale, domestic disruption, 15kg, DUVDEVAN, debugging, Bluebird, Ionosphere, Keyhole, NABS, Kilderkin, Artichoke, Badger, spookwords, EuroFed, SP4, Crypto AG a few, alleged, Echelon keywords. Please add some to your email signature. Full list: http://www.serendipity.li/cia/bz1.html
    http://www.nosoftwarepatents.com/

  5. #5
    Join Date
    Sep 1999
    Location
    Cambridge, UK
    Posts
    509
    > file is a shell operation. It's independent of the command run.
    Code:
    > tee echo 4 f3
    is the same as well.

  6. #6
    Join Date
    Mar 2003
    Location
    UK
    Posts
    621
    Quote Originally Posted by furrycat View Post
    > file is a shell operation. It's independent of the command run.
    Code:
    > tee echo 4 f3
    is the same as well.
    Gracias. Who'd have thought it, very strange, perhaps the rationale is 'It's not ambiguous so allow it.'
    MI6, Offensive Information, Hackers, Encryption, UFO, AOL, Infowar, Bubba, benelux, Ufologico Nazionale, domestic disruption, 15kg, DUVDEVAN, debugging, Bluebird, Ionosphere, Keyhole, NABS, Kilderkin, Artichoke, Badger, spookwords, EuroFed, SP4, Crypto AG a few, alleged, Echelon keywords. Please add some to your email signature. Full list: http://www.serendipity.li/cia/bz1.html
    http://www.nosoftwarepatents.com/

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •