View the Most Wanted LQ Wiki articles.
Go Back > Forums > Linux Forums > Linux - Newbie
User Name
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!


  Search this Thread
Old 10-29-2009, 09:35 AM   #16
Senior Member
Registered: Oct 2004
Location: Houston, TX (usa)
Distribution: MEPIS, Debian, Knoppix,
Posts: 4,727
Blog Entries: 15

Rep: Reputation: 231Reputation: 231Reputation: 231
All rolled into one

Great thread, I had forgotten some of the suggestions.

Here is code embodying all of the above, plus uname -a. It can be redundant, but it is comprehensive.
# find *nix distro/version/release info.

_divider () {
  echo -e "======================\n"$@"\n-----------------"

_execute () {
  _divider $@

# main line, pipable or redirectable
_execute  lsb_release -a

for X in  {/etc/*{release,version}*,/proc/version}
   _divider $X
   cat $X

_execute  uname -a
}  | less -S
Tested on "MEPIS 7.0 (upgradable from Debian etch)".

Hints, lessons, explanations -- skip this if you understand the code.
  1. It's modular -- You can add new, delete the useless (to you), & rearrange the presentation order.
  2. Nicely formatted output.
  3. You can send the output wherever you want.
  4. Functions hold repeated code, for:
    1. less typing.
    2. modular debugging,
    3. making changes in one place.
  5. 2-1/2 uses of braces:
    1. to enclose the body of a function -- this is the half, it's really a special case of iii)
      (see bash man page at "Shell Function Definitions"),
    2. brace expansion - "{/etc/*{release,version}*,/proc/version}"
      (see bash man page at "brace expansion is"),
    3. Compound Commands - enclosing the body of the functions & enclosing the main line for piping or redirection
      (see bash man page at "Compound Commands"),
  6. "-e" option for echo (man echo)
  7. "$@" positional parameter (see bash man page at "several parameters specially")
  8. "-S" option for less (man less)



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
How to find the linux operating system version in SLES/RHEL? vedam.psg Linux - Software 4 03-11-2014 07:49 AM
What Command shows my operating system? john test Linux - Newbie 11 07-20-2008 08:26 PM
can't find operating system error at boot MoXplorer Linux - Software 2 05-16-2007 10:21 AM
Need Command to find linux operating system information raajesh_ak Linux - Newbie 9 12-21-2005 06:38 PM
dd command - missing operating system samnjengah Linux - General 8 01-08-2004 01:49 PM

All times are GMT -5. The time now is 08:38 AM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration