Thursday, July 30, 2015

Output from rpm -qa, how to extract only the name of the package?

If you need to migrate to a new computer and want to install the same packages that were on your old computer on the new one, the following pipes all the packages into a list that you can then use to install on the new computer.

rpm -qa --qf "%{NAME}\n" > filelist.txt

Then to install the packages

yum -y install  `cat filelist.txt`
or
yum -y install $(cat filelist.txt)

Wednesday, July 29, 2015

How to show only settings and not the comments in a file

In Bash , ZSH or most shells. Comments are added in files using #   or sometinmes ;

Sometimes files are full of comments and finding the settings that are set amongst all the comments can be confusing.

The following will show you the contents of a file excluding lines begining with #

substitute the #   with a ;  if your program uses ;  to comment


grep -v '^#'  filename