bash: find last occurrence of a character in a string

Use cat or sed to append text to file

When writing shell scripts, you usually run into use cases where you want to manipulate text strings. Here we will see how you can find the last occurence of a single character in a string and then use that information to manipulate text or strings. For the purpose of this post, we will consider the character that we can to…

how to count the number of delimiters in a text file in linux

linux count characters, words, lines

It is easy enough to count lines in a text file, also it is easy enough to count characters with in a text file. So, counting delimiters in the text file should be just as simple. The delimiters are usually nothing but characters and counting those characters will give the count of delimiters in the file. For example, counting lines…

how to delete symbolic links in linux

Linking by cp in linux

Symbolic links and symlinks are one of the most popular features of posix based Linux systems. The symbolic links gives you the ability to duplicate files in the system with different names and location with out the need to create copies of the file. There are two different types of links that you can have in Linux: hard links and…

how to add extra spaces between text or words in html

html word spacing between text

When authoring web pages and programming in HTML, you might have noticed that no matter how many spaces you put between words or text elements they are get collapsed to one space when rendering the page. When writing text or sentences in most text processing software, you will be able to hit the space bar multiple times and add multiple…

how to delete all empty directories in linux

Linux command line delete files

You might already know that in Linux a directory have to be empty before it can be deleted. Well…not quite true, you can force delete the directories. What if you want to remove only empty directories recursively from the folder structure? There are a couple of different ways to do this. We will see some of the options from the…

how to set font size or size of text in html

Google Fonts

Defining the size of text in different contexts is important when designing and developing webpages. In HTML, there are primarily two different ways of specifying the font size or size of text. One is using the font tag and the other is using cascading style sheets or CSS. According to the latest W3C recommendations, the best way to change the…

linux: how to replace text in file from command line

vi editor and search expressions

Linux has several different utilities that can perform string or text manipulation. Depending on your environment and the tools that are available, you should be able to easily parse, find and replace any string in a text file. Almost every single text editor comes with a find and replace feature with a UI, so we are going to only explore…

how to enable and disable ssh in linux

linux config file for sshd

ssh or secure shell is a network protocol that allows you to perform various network services remotely and securely over an unsecured network. There are several different operations that can be performed using the ssh protocol. The most common are probably logging in or connecting to a remote machine and transferring files over the network to a remote machine. In…

vi editor: how to go to a line by line number

vi editor and search expressions

The vi or vim editor is the popular and feature rich editor for editing text files in Linux. You can go to a particular line in the editor in several ways depending on where you are accessing it from. from the command line If you are opening a file from the command line, and you want the cursor at a…

how to use secure copy (scp) to copy files in linux

linux cp command to copy folders

If you work with computers of any kind, sooner or later you will want to copy files between folders. Often times you want to copy files between machines or computers over a network as well. Secure Copy or scp allows you to copy files between hosts on a network. The files are copied over ssh or secure shell which allows…

how to delete lines in vi or vim editor in linux

vi editor and search expressions

If you use vi or vim editor to edit text files, then you should know different text manipulation commands that exist in the editor. One of the common actions you will perform is the deletion of a line or multiple lines from with in the editor. Let’s see the various ways you can delete a line in the vim editor….

how to use the tail command to view files in linux

tail command output in linux

There are several different ways to view text files in Linux. You can use a text editor such as vi or gedit. You can also use an utility like more or less that will print out the complete content of the file. tail is yet another utility that will allow you to view the contents of a file. However, there…