Find the answer to your Linux question:
Results 1 to 6 of 6
I need help writing my first script. When I run this script I need these information to be display: 1) The number of cores the system is using 2) The ...
  1. #1
    Just Joined!
    Join Date
    Sep 2008
    Posts
    26

    need command line help

    I need help writing my first script. When I run this script I need these information to be display:

    1) The number of cores the system is using
    2) The CPU thats related to the core
    3) Video card type
    4) Number of video cards the system is using
    5) Memory type
    6) How much memory the system has
    7) Last user that logged in

    Please advise on the command lines I need to display these information. Thanks in advance. (I am working with Debian Linux)

  2. #2
    Linux Engineer Freston's Avatar
    Join Date
    Mar 2007
    Location
    The Netherlands
    Posts
    1,047
    Quote Originally Posted by sidebrake
    I need help writing my first script.
    Is this a homework question??
    Hint: You can get an awful lot of info you are after from the /proc directory
    Can't tell an OS by it's GUI

  3. #3
    Just Joined!
    Join Date
    Sep 2008
    Posts
    26
    Quote Originally Posted by Freston View Post
    Is this a homework question??
    Hint: You can get an awful lot of info you are after from the /proc directory
    that helped out a lot, thanks.

    BTW: this is for work actually, my first .JR admin job... i should have paid attention in my linux classes during college.

  4. #4
    Just Joined!
    Join Date
    Sep 2008
    Posts
    26
    when i use the command:

    "cat /proc/cpuinfo | grep 'model name' | cut -d: -f2"

    i get this output:

    "Dual-Core AMD Opteron(tm) Processor 2222"
    "Dual-Core AMD Opteron(tm) Processor 2222"
    "Dual-Core AMD Opteron(tm) Processor 2222"
    "Dual-Core AMD Opteron(tm) Processor 2222"

    how do i make it so it will do a count for me instead of display all 4 outputs... for example i am looking for something like this:

    "Dual-Core AMD Opteron(tm) Processor 2222 = 4"

    Please advice thanks!

  5. #5
    Linux Guru
    Join Date
    Nov 2007
    Location
    Córdoba (Spain)
    Posts
    1,513
    Code:
    COUNT=$(cat /proc/cpuinfo | grep 'model name' | sed -e 's/.*: //' | wc -l)
    echo -n $(cat /proc/cpuinfo | grep 'model name' | sed -e 's/.*: //' | uniq) = $COUNT
    That's the basic idea on shell scripting. I changed cut by sed because I preffer it, and it can also take rid of that space that there was in front of the model name (just after the : colons that you use as a field delimiter).

  6. #6
    Just Joined!
    Join Date
    Sep 2008
    Posts
    26
    Quote Originally Posted by i92guboj View Post
    Code:
    COUNT=$(cat /proc/cpuinfo | grep 'model name' | sed -e 's/.*: //' | wc -l)
    echo -n $(cat /proc/cpuinfo | grep 'model name' | sed -e 's/.*: //' | uniq) = $COUNT
    That's the basic idea on shell scripting. I changed cut by sed because I preffer it, and it can also take rid of that space that there was in front of the model name (just after the : colons that you use as a field delimiter).
    thats exactly what i was looking for, thanks you!

Posting Permissions

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