Find the answer to your Linux question:
Results 1 to 3 of 3
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1

    Need help getting script to display output

    Hello all, what would be the best way to echo output of the following command. cat /etc/*release? I am putting this into a script that will look for other things but I cant figure out how to have it echo the output of the above command. Please help.

  2. #2
    Linux Guru
    Join Date
    Oct 2007
    Tucson AZ
    What programming language are you using? Just putting that command in a bash script and making the script executable would do it. If you are using something other than bash, post that info. If you have tried and failed, what is the problem/error you are getting.

  3. #3
    Quote Originally Posted by terrywhitejr2000 View Post
    cat /etc/*release?
    are you sure that is what you want? The asterisk there will be expanded by the shell into all files in /etc/ that end in 'release' and cat will get passed all of them. for example, look at this command on my system:

    $ ls -l /etc/*release
    -rw-r--r--. 1 root root  34 May  4  2012 /etc/fedora-release
    -rw-r--r--. 1 root root 165 May  4  2012 /etc/os-release
    lrwxrwxrwx. 1 root root  14 Jun  3  2012 /etc/redhat-release -> fedora-release
    lrwxrwxrwx. 1 root root  14 Jun  3  2012 /etc/system-release -> fedora-release
    so i have 4 files matching, and two of them are symlinks to a 3rd file. so if i were to run your cat command, i'd get the output of the same file three times, plus the output of another file, all jumbled together in STDOUT.

    maybe that's what you want, though, and might make sense if you only expect to have the wildcard match one file. but if there are multiple files, this is what i might do:

    find /etc/ -mindepth 1 -maxdepth 1 -type f -name '*release' -exec grep -H . {} \;
    this command will find only files (not symlinks) that end in 'release' and will cat the output to the terminal, but will proceed the output with the name of the file itself, for clarity, e.g.:

    /etc/fedora-release:Fedora release 17 (Beefy Miracle)
    /etc/os-release:VERSION="17 (Beefy Miracle)"
    /etc/os-release:PRETTY_NAME="Fedora 17 (Beefy Miracle)"

  4. $spacer_open

Posting Permissions

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