- Where Developers Learn, Share, & Build Careers


I am currently in the process of modifying a large BASH script which installs / checks a series of packages in a few different Districts. (Mainly Redhat and Debian based).

To handle some differences between distros (such as RPM versus DPKG, Wiim Vs, APT, etc.), I am trying to load some variables with different command strings so that the script is filled with If it is Debian, otherwise this statements, though it appears that it does not like to put awk inside an eval statement, and I do not know why it may be.

Example

# Examples DPKG - List Product # ii bash 4.1-2ubuntu3 GNU Born Again DPKG - List | Grep 'bash' # Output Bidding Entries in DPKG CMD = "DPKG - Listing | GRP 'Beash'" EVALE $ CMD # Production as expected, DPKG-list as above. Awk '/^.i/ {print $ 2}' # Output as expected, a list of package names Cmd = "dpkg --list | awk '/^.i/ {print $ 2}' 'eval $ cmd # Print out the full output from DPKG for each line that matches the regx.

In the code above, just looks fine for a given package, and prints as expected. , But when trying to prepare a complete list of package names using awk, then print $ 2 is ignored And just prints the whole line.

Any ideas?

This is the reason:

  cmd = "dpkg --list | Awk '/^.i/ {print $ 2}' 'echo $ cmd output: dpkg --list | $ Sign escape:  
  cmd = "dpkg --list | awk" / ^. I / {print \ $ 2} '" 

Comments

Popular posts from this blog

Python SQLAlchemy:AttributeError: Neither 'Column' object nor 'Comparator' object has an attribute 'schema' -

java - How not to audit a join table and related entities using Hibernate Envers? -

mongodb - CakePHP paginator ignoring order, but only for certain values -