File filters commands in Linux

Linux distributions come with various powerful file filtering commands. You can get fast results just with the help of some simple commands.

Different file filter commands used in Linux are as follows: 

1) wc: 
To see the no of characters in a file - $wc - c <file name>
To see the no of words in a file - $wc -w <file name>
To see the no of lines in a file - $wc -l <file name>
To see the no of lines, words, characters at a time - $wc <file name>

2) Pipe ( | ) :
We can carry out piping between two commands. Here, the standard output of first command is taken as the standard input for the second command.
<Command1> | <command2>   e.g. $ll | wc

3) head :
To see the top 10 lines of a file - $head <file name>
To see the top 5 lines of a file - $head -5 <file name>  

4) tail :
To see last 10 lines of a file - $tail < file name>
To see last 20 lines of a file - $tail -20 <file name> 

5) more
To see the contents of a file in the form of page views - $more <file name>
e.g . $more f1.txt
                
6) sed : 
It is used to cut the information horizontally.
To see the first line in file sun, 
$sed -n 1p sun
To see 3 to 5 lines
$sed -n '3,5p' sun

7) grep
To search a pattern of word in a file, grep file is used.
syntax $grep < word name> < file name>
$grep hi file_1  
To search multiple words in a file
$grep -E ' word1|word2|word3|' <file name>
e.g. $grep -E 'hi|beyond|good' file_1

8) sort
This command is used to sort the file .
$sort  <file name>
e.g.: $sort file_1
To sort the files in reverse order
$sort -r <file name>

To display only files  
$ll | grep "^-"
To display only directories
$ll | grep "^d"

4 comments:

We are a third party technical support service. Avast Customer Support is here to help you out with the whole procedure to Download Avast Antivirus online, We not only fix your Avast Support related issues but will guide with how to get started with your new Avast product once it gets installed successfully.We at Avast Tech Support provides service to protect your PC from potential online threats and external attacks like viruses, Trojans, malwares, spywares and phishing scams. And Avast Refund. Call on our Avast Phone Number.
Norton Tech Support is a third party service provider and not in any way associated with Norton or any of its partner companies. At Norton Support we offer support for Norton products and sell subscription based additional warranty on computer and other peripheral devices.

[url=http://supportfornorton.com/ ]Norton Tech Support[/url] is a third party service provider and not in any way associated with Norton or any of its partner companies. We offer support for Norton products and sell subscription based additional warranty on computer and other peripheral devices. Call our Toll Free number 1 855 966 3855

The Antivirus Package protects one device and works on IOS, Windows, Android and MAC. It includes real time protection, virus, spyware, Malware and phishing protection.

Norton.com/setup
Norton.com setup
Norton setup

Post a Comment