PIPE (UNNAMED PIPE) – In this linux commands tutorial, you will understand how to use pipe command in linux with command and bash script examples.
- In shell, the output of command is given to input of another command that is called as pipe or unnamed pipe
- In terminal it is indicated by | symbol
Syntax
Example
Example 2: Count all the shell (.sh) files in current directory using Pipe command
I. DISPLAYING TOTAL OF SHELL FILES IN CURRENT DIRECTORY USING PIPE
1. SOURCE CODE
echo “———————————————-“
echo “\t\tCounting Shell Files in File System using Pipe (|)”
echo “———————————————-“
# count total number of files using pipe
ts=`ls | grep .sh | wc -l`
if [ $ts != 0 ]
then
echo “Total Number of Shell Files: $ts”
else
echo “No Shell Files Found in File System…”
fi
2. OUTPUT
OTHER TUTORIALS
-
How to convert Word to Number in Bash Script
FacebookTweetPinLinkedInEmailShares0SharePrint In this bash tutorial, you will get convert word to number in bash script with examples.This is implemented using for loop, tr command, switch case in shell…
-
How to Count Word Frequency in Bash Script
FacebookTweetPinLinkedInEmailShares0SharePrint In this bash tutorial, you will get the program about how to count word frequency in bash script. This is done by using for loop,…
-
Bash Script – How to convert Number to Words
FacebookTweetPinLinkedInEmailShares0SharePrint In this tutorial, you will see how to convert numbers to words using bash script. This shell script can be done with the help of switch case…