How To Use Pipe Command In Linux?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
1. To view the contents of a file:
The ‘cat’ command is the most basic command in Linux used to view the contents of a file. To view the contents of a file using the pipe command, you can use the command ‘cat <filename>’ | less. This will pipe the contents of the file to the less command, which allows you to page through the file.
2. To filter or sort data:
The pipe command can be used to filter or sort data from a list or table. For example, if you have a list of employee names and ages, you can use the command ‘cat employee_list.txt’ | sort –nr to sort the list in descending order by age.
3. To combine commands:
The pipe command can be used to combine multiple commands into a single command. For example, you can use the command ‘ls -l’ | grep ‘*.txt’ to search for all files with the .txt extension in the current directory.