Re: simple shell script question

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



unclear what you are trying to accomplish here.  If, for example, you are trying to pgrep for all processes that have 'bash' in the process name:
#!/bin/bash
aa='bash'
xx="pgrep -f ${aa} | wc -l"
echo $xx <<< shows the command in $xx
eval ${xx} <<< runs the command in $xx


---


Regards,

Kevin Martin

On Wed, Aug 9, 2017 at 7:47 PM, bruce <badouglas@xxxxxxxxx> wrote:
trying to get the following to output
  pgrep -f 'bash' | wc -l

  the var $xx has the cmd...
  something's missing to allow the backtics to run the cmd..
  if the cmd is hadcoded.run, it works..

can't see what the homer simpson "doh" moment is!

thanks



#!/bin/bash
#
# ptest.sh
#
# use predefined variables to access passed arguments
#
# $1
aa=$1
aa='bash'
echo $aa " pp"
xx="pgrep -f '"${aa}"' | wc -l"
echo $xx   <<< this dsplays the test pgrep
echo `$xx`   <<  err msg
echo `${xx}`  << err msg...

## trying to get -- pgrep -f 'bash' | wc -l <<
## i'm getting a Usage: pgrep [....] err msg..
_______________________________________________
users mailing list -- users@xxxxxxxxxxxxxxxxxxxxxxx
To unsubscribe send an email to users-leave@lists.fedoraproject.org

_______________________________________________
users mailing list -- users@xxxxxxxxxxxxxxxxxxxxxxx
To unsubscribe send an email to users-leave@xxxxxxxxxxxxxxxxxxxxxxx
[Index of Archives]     [Older Fedora Users]     [Fedora Announce]     [Fedora Package Announce]     [EPEL Announce]     [EPEL Devel]     [Fedora Magazine]     [Fedora Summer Coding]     [Fedora Laptop]     [Fedora Cloud]     [Fedora Advisory Board]     [Fedora Education]     [Fedora Security]     [Fedora Scitech]     [Fedora Robotics]     [Fedora Infrastructure]     [Fedora Websites]     [Anaconda Devel]     [Fedora Devel Java]     [Fedora Desktop]     [Fedora Fonts]     [Fedora Marketing]     [Fedora Management Tools]     [Fedora Mentors]     [Fedora Package Review]     [Fedora R Devel]     [Fedora PHP Devel]     [Kickstart]     [Fedora Music]     [Fedora Packaging]     [Fedora SELinux]     [Fedora Legal]     [Fedora Kernel]     [Fedora OCaml]     [Coolkey]     [Virtualization Tools]     [ET Management Tools]     [Yum Users]     [Yosemite News]     [Gnome Users]     [KDE Users]     [Fedora Art]     [Fedora Docs]     [Fedora Sparc]     [Libvirt Users]     [Fedora ARM]

  Powered by Linux