Recent Posts

ads

Output filters: &&,cut , Sort Uniq and Grep














Sort  File sort utility, often used as a filter in a pipe. This command sorts a text stream or file forwards or backwards, or according to various keys or character positions. 

Uniq This filter removes duplicate lines from a sorted file. It is often seen in a pipe coupled with sor
t
Cut A tool for extracting fields from files. It is similar to the print $N command set in awk, but more limited. It may be simpler to use cut in a script than awk. Particularly important are the -d (delimiter) and -f (field specifier) options.


Grep A   multi-purpose file search tool that uses Regular Expressions. It was originally a command/filter in the venerable ed line editor: g/re/p -- global - regular expression - print.

&&: And operators.   IF this is true , it will run the next thing
If this is NOT true, don't run the next thing.. It works as IF in programming.


Operator (&&)

The AND Operator (&&) would execute the second command only, if the execution of first command SUCCEEDS, i.e., the exit status of the first command is 0. This command is very useful in checking the execution status of last command.





So we got this file called My wonderful file



WE will try to run it.



the last command had an error in the name of the file, so it 's not true and it won't run it.


Sort, a UNIX and Linux command for sorting lines of text files. You can be sorting in alphabetical order, reverse order sorting, sorting by number, and mixed case sorting.


Now check the other output in a filed called a anewoutput2.txt






Cut command is for cutting out the sections from each line of files and writing the result to standard output. It can be used to cut parts of a line by byte position, character, and field. Basically the cut command slices a line and extracts the text.




Uniq: The uniq command in Linux is a command-line utility that reports or filters out the repeated lines in a file. In simple words, uniq is the tool that helps to detect the adjacent duplicate lines and also deletes the duplicate lines.


We will make a duplicate using nano text editor





We save it with Crtl +O  and CTRL + X to exit









WC Command Count Number of Lines, Words, Characters in Linux.








Grep command in Unix/Linux is a is an interesting find and filtering tool.. The grep filter searches a file for a particular pattern of characters and displays all lines that contain that pattern. The pattern that is searched in the file is referred to as the regular expression (grep stands for globally search for regular expression and print out)




Grep is awesome for filtering and finish some lines that you are looking for..


Miami and great are the first names in the previous files that we made





Now we want to filter where which file  put the name Bono..We need to filter all the places..






So you learned how to use  how &&, Sort ,Uniq,Cut, WC and Grep work.

If you like it and understood please click like!

Output filters: &&,cut , Sort Uniq and Grep Output filters: &&,cut , Sort Uniq and Grep Reviewed by ohhhvictor on August 09, 2018 Rating: 5

No comments:

Facebook

ads
Powered by Blogger.