Find the answer to your Linux question:
Results 1 to 2 of 2
Code: #!/bin/bash echo 'obase=2;10'|bc current_version=$1 echo $current_version echo 'obase=2; $current_version'|bc > BinVer.txt What is the problem? The terminal tells me the $ sign is illegal. Help?...
  1. #1
    Just Joined!
    Join Date
    Apr 2011
    Posts
    5

    Creating bash file that changes decimal to binary using obase

    Code:
    #!/bin/bash
    
    echo 'obase=2;10'|bc 
    
    current_version=$1
    echo $current_version
    
    echo   'obase=2; $current_version'|bc    > BinVer.txt
    What is the problem? The terminal tells me the $ sign is illegal. Help?

  2. #2
    Just Joined!
    Join Date
    Mar 2007
    Location
    Bogotá, Colombia
    Posts
    39
    Quote Originally Posted by hayloiuy View Post
    Code:
    #!/bin/bash
    
    echo 'obase=2;10'|bc 
    
    current_version=$1
    echo $current_version
    
    echo   'obase=2; $current_version'|bc    > BinVer.txt
    What is the problem? The terminal tells me the $ sign is illegal. Help?
    Your problem seems to be the single quotes in the echoes, try this:

    Code:
    #!/bin/bash
    
    echo "obase=2;10" | bc 
    
    current_version=$1
    echo $current_version
    
    echo "obase=2; $current_version" | bc > BinVer.txt

Posting Permissions

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