Little help with a Bash script
Hello everyone.
First I'd like to say I'm not a programmer or something like that. I made a simple Bash script to get system information. It's working well with my computer [Manjaro] and few others. [Ubuntu and Fedora] So I wanna know is this working with other distributions as well? Anyone can help me? Suggestion are always welcome. Here's my script. Thanks in advance. Code:
#!/bin/bash |
Bump
|
A few comments, although very nice overall :)
1. Does not cater for those of us not using one of the DE's you have listed or maybe just a WM 2. See here for comments on not needing to use cat on any of the lines where you have, ie grep or sed can both read a file 3. You constantly call grep with -i to remove any case sensitivity, yet when calling the sed to remove the same item you make no such requirement. I would suggest that all references with grep to -i are not needed 4. The use of escapes as opposed to simple quoting, ie Product\ Name or just 'Product Name' 5. As grep is not generally doing any heavy lifting, I would simply use sed to search for your item, eg Code:
# current Code:
# current You also the capture the output of your command but never use it?? Maybe you could just test the variables you set if you return what you are looking for? 8. Instead of requiring root, which from a little testing I think (could be wrong) is only needed for the calls to dmidecode, maybe you could put in an if that if not root you get all but dmidecode associated info otherwise you get the lot ... just a thought 9. I notice you have setup 'bold' and 'regular', but then you call the raw form for colours ... why not set that up in a variable to? This way someone else can change to preferred colour in one spot instead of several times throughout your script Hope some of that helps :) |
A few things that come to mind. lsb_release is not installed by default, at least on the Redhat based systems that I use. The same is true for dmidecode. The script will error out on these issues.
|
do not use cat filename | grep whatever, grep whatever filename will work too.
do not use sed pattern1 | sed pattern2 | sed patternX, it can be solved with one single sed for example these lines (8 new processes): Code:
echo "Graphic vendor :" $(glxinfo | grep -i OpenGL\ vendor\ string | sed 's/OpenGL vendor string://g') |
@grail and @pan64 - Got it. Thanks in advance.
|
Here is a quick change up of the same (assuming all applications are installed, as pointed out by Glennzo) and I am unable to change the DE section as I do not currently run
one, ie I use openbox, and don't have a VM with any on: Code:
#!/bin/bash |
Thanks for re-scripting it. I didn't really expect it. As I see linuxquestions.org is very helpful forum. Saying once again THANKS EVERYONE.
@grail - A bit a personal question. As I see you're using Manjaro. Am I know you? |
Can I know output of this command in a computer like i5 or i7?
Code:
sed -n '/cache size/{s/^.*: //p;q}' /proc/cpuinfo Code:
sed -rn '/model name/{s/^.*: |CPU//g;s/G/ &/p;q}' /proc/cpuinfo |
Quote:
I am running on an i7 so here is the output I receive: Code:
$ sed -n '/cache size/{s/^.*: //p;q}' /proc/cpuinfo Code:
$ sed -n '/cores/{s/^.*: //p;q}' /proc/cpuinfo |
I'd like to keep that one. And another one question here. Why did you add same command twice in here? Is it typo?
Code:
Audio card(s) : $(lspci | sed -n '/audio/{s/^.*: //p;q}') $(lspci | sed -n '/Audio/{s/^.*: //p;q}') |
If you look closely you will see that one has a capital A. I was not sure what the first was supposed to return as on my machine your script returned nothing for the first audio item.
|
I would prefer this one:
Code:
lspci | sed -n '/[Aa]udio/{s/^.*: /Audio card(s) : /p}' Code:
# instead of: |
But it did return my audio card twice.
|
Quote:
|
All times are GMT -5. The time now is 02:17 PM. |