How about this? Is this working?
Code:
#!/bin/bash |
no, at least there is a problem with it (what I found):
it creates 3 files and you ought to use full path for them: XFCE=/tmp/xfce or similar and use $XFCE in the script. Now the execution depends on the current directory. Also instead ps -e | grep you can try pgrep the line: kded4 --version | grep -m 1 'KDE' | awk -F ':' '{print $2}' | awk '{print $1}' is ugly, you can solve it with a single awk kde4 --version | awk ' blabla ' Code:
(I have no kde, so cannot test it, but something like this should do the job) xfce4-session --version | awk '/xfce4-session/{print $2}' |
I would actually still urge against creating any files ... there does not seem to be any point when you could just as easily test a variable within the script as opposed to going
out to a file which you then have to clean up. Plus I find it invasive to have a script create files on my system. I have taken pan64's suggestion about grouping to see if we could help the processing time. See if this helps: Code:
#!/bin/bash |
Thanks for the help everyone. I'll take it.
@pan64, I don't have KDE either. So how can I check is it working or not? Anyway thanks for help. |
I would probably suggest downloading an iso and making a vm with all the different choices you wish to test for and away you go :)
|
Quote:
|
Quote:
Code:
pgrep xfce4-session Code:
#!/bin/bash |
Quote:
Code:
root@host:~$ sed -n '/cache size/{s/^.*: //p;q}' /proc/cpuinfo Code:
root@host:~$ sed -n '/cache size/{s/^.*: //p;q}' /proc/cpuinfo |
Thanks joe_2000.
|
I made it with your help and suggestions. How about this? Any suggestions for this?
Code:
#!/bin/bash |
Bump
|
Please don't 'bump' as everyone is volunteering help so it is perceived as impolite to try and force an answer.
I am still not sure why you persist with using files at all. Also, by using a specific word and not a random name you can hit an issue where you might overwrite a file on someone's system, ie. if /tmp/xfce already exists and you call the following code: Code:
pgrep xfce4-session > /tmp/xfce; XFCE=/tmp/xfce As I have said several times, why not simply store the value in a variable and then test that: Code:
XFCE=$(pgrep xfce4-session) |
Sorry for the "bump".
That's what I want to know. I wanted to store value in a variable too but I stuck at somewhere and I didn't know where it is. So I gave up it. As I see now, I didn't add "[[ .. ]]" before. That's it. Thanks for the help. EDIT : As you see, I'm a noob in this Bash stuff. And I want to say, I didn't refer any Bash/Shell guide to make this so far. So, some of commands may be wrong and stupid. That's why I'm asking for help here. Thanks. |
Well here are a couple to help you investigate further:
http://tldp.org/LDP/abs/html/ http://mywiki.wooledge.org/TitleIndex |
Quote:
To store the result of a command in a variable use: VARIABLE=$(command) - [[ and ]] is used in comparison. Quote:
|
All times are GMT -5. The time now is 05:58 PM. |