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 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…

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 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 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…

how to list processes in linux from command prompt

ps command output

Processes or Tasks are the executing instances of a particular application or program in an operating system. All running programs including operating system will have its own process. Also, you can have multiple instances of the same program running, each of which will have separate processes. In addition to the top level processes, there can also be child processes. A…