Tag: grep

Interesting Results when using cat with grep vs only grep

A typical situation is one where there is a directory that contains many files. Maybe 100s of files or more. Searching through however many files for a specific string can get annoying, however, here are a couple of ways to do just that. Note that there are many more, but this really isn’t the point of this article. A use…

Read More »
Linux Logo

Use grep or awk to eliminate blank lines and comments

A configuration file, specifically, the /etc/samba/smb.conf file contains many lines of comments using both the simi-colon (“;“) and the hash (“#“) as well as many empty lines that are either blank or contain whitespace. Using grep to view the file without these lines is one way to do so. To write the correct command can be a bit more challenging….

Read More »

Match empty lines and commented lines using grep

An example of a configuration file with many commented lines is /etc/sysctl.conf. If you wanted to display the contents of the file without the commented lines, the following command may be issued. However the resulting contents will be displayed with the remaining blank lines. To get around this one of a couple of commands may be issued. Source(s) http://stackoverflow.com/questions/18566169/match-empty-lines-in-a-file-grep http://stackoverflow.com/questions/3432555/remove-blank-lines-with-grep

Read More »
Linux Logo

Command to Check if Linux is Running in VMware or not

Only having terminal access to a server running CentOS 5.7, I had to determine if the server was actually a physical or virtual machine. There are a few methods to do this, however, here are a couple of the easier methods. Vendor: VMware Model: Virtual disk Rev: 1.0 Vendor: VMware Model: Virtual disk Rev: 1.0 Vendor: VMware Model: Virtual disk…

Read More »