I recently found that xlsclients -a(l) is a pretty useful tool to get window programs.
Quote:
You may want to filter the output from grep through awk or sed to remove unneeded information. If you remove all but the second column, you're left with just the PID.
|
In that case it's:
Code:
var=$(ps aux | grep "watever" | awk '{print $2}')
To strictly follow your method of thinking:
Code:
FILE="shit.txt"
echo $(ps aux) > $FILE
var=$(cat "$FILE" | grep "watever" | awk '{print $2}')
echo "$var"
In both scripting (commandline is also equally important), a double quote ", doesn't seem too obvious at writing the script, but when running, vars with spaces can often cause unwanted troubles.
Ted