Skip to main content

Thread: How to do Complex Variables


hey guys,

im novice scripting gental.

okay script:
#!/bin/bash

echo "what process need?"
read process
input="ps aux |grep $process | grep -v grep | awk '{print $2}'"
kill $input
now input giving me issues when runs line $process doesnt picked up. can suggest better way of doing this?

kind regards,
fenlig

you need use command substitution. in script $input string inside double quotes. instead of

code:
input="ps aux |grep $process | grep -v grep | awk '{print $2}'"
you need

code:
input=$(ps aux |grep $process | grep -v grep | awk '{print $2}')
see here http://mywiki.wooledge.org/bashguide/specialcharacters

quote variables , use lower case variables.


Forum The Ubuntu Forum Community Ubuntu Specialised Support Development & Programming Programming Talk [SOLVED] How to do Complex Variables


Ubuntu

Comments

Popular posts from this blog

How to set the order of FAQs instead of alphabetical

Thread: Get UK Keyboard working

how do I change the e-mail address for my merchant account