Convert text files within a directory from Windows to Unix format
When a file is saved in Windows and then moved to a Linux system the formatting differences can cause a variety of problems. To effectively use these files you will need to change the format from Windows/DOS to Unix. This conversion occurs by simply removing the Windows carriage return characters.
I have explained how to use [...]
Command substitution in BASH
BASH has the ability to execute a command string and replace that string with the output of the command. Or to say it another way, the output of a command will replace the command itself.
There are 2 ways to accomplish this.
The first is to surround the command with backticks or blockquotes.
`command`
You can also substitute with [...]
Delete a specific line from a text file with sed
At some point you may have the need to remove all lines within a text file that match a certain pattern. Accomplishing this is easy with the sed command.
Here is the command format.
$ sed -i ‘/PATTERN/ d’ file.txt
The ‘-i‘ option allows you to edit the specified file in place.
PATTERN is a regular expression
d [...]
How to correctly use LD_LIBRARY_PATH
The LD_LIBRARY_PATH environment variable contains a colon separated list of paths that the linker uses to resolve library dependencies of ELF executables at run-time. These paths will be given priority over the standard library paths /lib and /usr/lib. The standard paths will still be searched, but only after the list of paths in LD_LIBRARY_PATH [...]
Customize the BASH PS1 command prompt
The PS1 environment controls the appearance of the BASH command line prompt. There are a variety of default prompts but they usually include username, hostname, and working directory. You can easily customize your prompt to display information important to you as well as add color and style formatting.
Here we can see the default prompt is [...]
I/O redirection in BASH
One of the best features of the Linux command line is the ability to efficiently direct input and output to and from files and other programs.
Every program begins with 3 open file streams.
stdin (file descriptor 0) - input from the user, usually keyboard
stdout (file descriptor 1) - standard output that is displayed on the screen
stderr [...]
Single versus double quotes in BASH
Understanding the difference between double versus single quotes is important when using BASH. Many times you may have seen them being used interchangeably. The basic difference is that variable names will be expanded within double quotes but not within single ones.
This example shows the normal output with no quotes.
$ echo $USER
ryan
As you can see [...]
