Find the answer to your Linux question:
Results 1 to 3 of 3
Hi all I have a question related with variables. Let's assume that I have one .txt file in my /tmp directory. Look here: #!/bin/sh var='/tmp/*.txt' echo var I'm getting /tmp/file.txt ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Just Joined!
    Join Date
    Jan 2007
    Posts
    10

    echo $var Problem


    Hi all
    I have a question related with variables. Let's assume that I have one .txt file in my /tmp directory. Look here:

    #!/bin/sh
    var='/tmp/*.txt'
    echo var

    I'm getting
    /tmp/file.txt

    That's ok

    Now I want the file name to be displayed in this sitaution to :
    echo "file=>$var"

    It shows
    file=>/tmp/*.txt

    But I want it to be shown as
    file=>/tmp/file.txt

    How can I solve it?
    Thanks ...

  2. #2
    Linux User
    Join Date
    Jan 2006
    Posts
    414
    tried removing the quotes?

  3. #3
    Super Moderator Roxoff's Avatar
    Join Date
    Aug 2005
    Location
    Nottingham, England
    Posts
    3,844
    So you want

    Code:
    #!/bin/sh
    var='/tmp/*.txt'
    echo var
    to show

    Code:
    file=>/tmp/file.txt
    ... how about you change to:

    Code:
    #!/bin/sh
    var='/tmp/file.txt'
    echo var
    You are, after all, echoing out a literal variable here.
    Linux user #126863 - see http://linuxcounter.net/

Posting Permissions

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