Do not use cat when you can avoid it. This is very annoying.

The unneeded use of the cat command is very annoying, this is wasteful. Something like this is very annoying to see. cat unixhell.txt | sed ‘s/program/application/g’cat unixhell.txt | sed ‘s/program/application/g’ Do it like this instead. This is the proper way to use sed. sed ‘s/program/application/g’ unixhell.txtsed ‘s/program/application/g’ unixhell.txt The user…

Read More

How to cat a gzipped logfile with gunzip properly.

The gunzip utility can uncompress logfiles that are gzipped in archives, but this is not needed. To read a logfile that is gzipped, you can also use this command to print the contents to a terminal and not bother uncompressing the file. This allows reading log files in /var/log without…

Read More

The proper way to use grep without cat. And some nice tricks.

This is the proper way to use grep. You do not need to use cat at all. This method works well and is one command, not two piping together. jason@jason-desktop:~/Documents$ grep apt-get ../.bash_history sudo apt-get update sudo apt-get install me-tv sudo apt-get update && sudo apt-get install xvst apt-get moo…

Read More

How to read a file and display the contents with Python.

How to read a file and display the contents with Python. This sample code reads and outputs the contents of a file using Python. This is a very simple code sample for reading in a file and displaying it. #!/usr/bin/env python   forme = "f.txt";   # Read a file…

Read More

Linux commands that prove useful for your day to day workflow.

The UNIX tail command is very useful for viewing the last number of lines of a logfile. As in this example. Showing the last 10 lines in the file /var/log/syslog. |{~}-{Thu Feb 16 21:36:44} -{john@deep-thought } $ tail -n 10 /var/log/syslog Feb 16 21:31:01 deep-thought cron[1480]: (*system*anacron) WRONG FILE OWNER…

Read More