sed command
sed Command, used for filtering and transforming complex data, acts as a powerful stream editor and is mostly applied in the shell or dev jobs for filtering out complex data. Using the sed command we can retrieve only the required lines of input text data by specifying the required index value.
Syntax of sed command:
sed OPTIONS… [SCRIPT] [INPUTFILE…]
Sample code:
Let us create a sample text file that contains some user names and their mail ids.
cat > data.txt
Now, let’s implement the sed command to retrieve input values starting from the 2nd index to the 5th index value only.
sed -n '2,5p' data.txt
Output:
Explanation:
In this section, we have filtered and transformed the data.txt file contents and outputted less complex data which can be easily viewed by the users.
Useful Commands For Filtering Text for Effective File Operations in Linux
In this article, let us learn about different commands used in Linux for filtering text to implement effective file operations on Linux Machines.