Grep
grep command is used to find texts from any text input. Passwd file: stores information about all the users in the system.
➔ Finding line which contains word as “root” from /etc/passwd file.
➔ Linux is case sensitive, Root is different that root. Ignoring case in grep with -i option.
➔ To display things except the given word use -v option
Filter Commands
• less: Displays file content page wise or line wise. Ex: less /etc/passwd
• more
• head
• tail
• cut
• sed
I/O redirection
I/O redirection is accomplished using a redirection operator which allows the user to specify the input or output data be redirected to (or from) a file. Note that redirection always results in the data stream going to or coming from a file (the terminal is also considered a file).
➔ Create a file named DevOps tools with below content.
➔ Search for text “tech” replace it with “tools” and redirect output to a new file.
➔ Appending another output in same file with “>>” .
➔ Redirecting only error to a file “2>>”.
➔ Redirecting all the output to a file “&>>”.
Piping
So far we've dealt with sending data to and from files. Now we'll look at a mechanism for sending data from one program to another. It's called piping and the operator we use is ( | ). What this operator does is feed the output from the program on the left as input to the program on the right.
Find
The 'find' command is your go-to tool for locating files and directories in a Linux system. It's versatile, allowing you to search based on name, size, type, and other criteria. Let's dive into the basic usage of the 'find' command.
Top comments (0)