Text Manipulation
Explore fundamental Linux text manipulation techniques including file and folder creation and removal. Learn how to view, append, and edit files using commands like cat and echo. Gain practical skills with the Vim editor, mastering insert and command modes to efficiently edit text files within Linux environments.
Introduction to text manipulation
This lesson introduces multiple ways of manipulating text in files. We will also be looking into file and folder creation.
Creating files and folders
We can create a folder using mkdir, which is a utility for the creation of directories in the Linux system. Simply provide a name for the new directory with mkdir, and we’re good to go.
We can use the touch command for file creation, though it can also be used to modify the timestamps of files and directories. Again, we simply provide the name and extension for the file we’d like to create.
The terminal below shows how we create a new folder called world and then create a text file inside it called hello.txt.
Removing files and folders
We can remove files and folders with the rm command. To remove individual files, simply provide their name with the command. Removing folders is slightly trickier; empty folders require the -d option, while non-empty folders require the -r option. The latter option recursively removes everything ...