Unix Filters | UNIX Tutorial | Mr. Subba Raju

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hi guys welcome to nourish a Technologies this is subbaraj you will see another unix video session with unix filters filter means which is going to be filter whatever we required as output for example two files we are giving input we required some lines in these two files these two file some lines I am da redirecting to third file so that is a filter there are the many filters in the UNIX operating system which we are using frequently in the IT environment I am showing first one head it is always displaying top of the file means if you open one file I want first lines 10 lines 20 lines 30 lines it is top to bottom displaying same opposite is tail tail always displaying from bottom to top NL number line you are going to put a prefix as a number for example in in your file 10 lines available I want to start every line with the 1 number 2 number like that but already file is there already file is there lines available but line numbers are not there I want to assign means I am doing NL number the line next one cut cut is nothing but very excellent command in the database environment area it is showing always table output in columns format generally when we are writing sequel queries we are bringing the data only rows wise cut is the boot cut beauties it is displaying columns wise also by using - f fields next one paste paste e is nothing but merging lines of X file it is merging parallely as well as serially perrolli means side by side serial means one after another one shot shorty is nothing but sorting the data sorting the data and displaying on Senate output device swatting the data and displaying in another file also TR TR means that translate translate is nothing but converting into one format to another format for example lowercase characters available in my file I want to convert into uppercase then we are using TR translating field that means one setter - and options also we are providing and translate is an excellent command we can do number of options in TR I will show you practically twe is nothing but by redirection l UNIX filter previously explained you know in my previous video very clearly redirection Allah / Attis it is a bi-directional operator means at a time we can send one output more than one screen more than one file is called bi-directional next one sed is nothing but stream editor it is completely working based on text related operations stream editor is one fine operate sorry fine UNIX command and grep globally such for regular expression it is an excellent command to find or - such strings in files grep f grip a grip it is a graph family as I said globally such for regular expressions it is a main duty of these three filters these are searching strings in files or in file now several options available in this video session I will concentrate more on these graph areas because in every interview panel mainly UNIX related interviews maximum questions are coming grep related because these are the reporting filters type searching filters time so what are options available practically each and every filter one by one will try to observe including options and first head-tail these are the line filters this is the number filter cut and paste we are calling as merge filters sort the sorting filter TR in TW translate filters said stream editor these are searching filters so different different names also available as per their name their characteristics also available yeah guys practically we can see one by one whatever the commands I shared with you first one is hand HEA D head it always displays first two lines in the file or the files first lines in the sensor by default first 10 lines displays will see what is man had man head output the first part of files had the always working top to bottom tail always working bottom to top and syntax had the option file name print the first 10 lines of each file and several options also available bytes quite - n number of lines v bar Bo's like this several options available we'll observe first I am opening one file LS there is a file available Big Five I want to click that so it contains 20 lines I want to see first head had big file by default of first 10 lines so head always bringing the first part I want for example only first 3 lines I want for example only first 5 lines - fine like this we can use a number of lines also now head and I required file name also then you can use verbose and it is giving the file name and by default file name it doesn't supports for example I am giving two lines just V is not there without file am two lines displayed so like this it is always bringing from top to bottom manner let me clear this I am giving at a time to file names here there is a cat names one available six lines available already 20 lines in big file both lines I want to display had first time giving name I fun three names one is faster three lines from the names one and big five so big file from big foil first three lines from names one first three lines with the file names verbose not required here you you are giving only one file verbose mandatory so like this with file names it is bringing but by default first 10 lines same like that lab sir that tail also so whenever we are going to see tail it is always bottom to top output last part of files same syntax just tail same options whatever we implemented maximum and I will try to show you this tail related operations tail hands-on experience we can tail and I want last 10 lines big file last 10 lines I want the last 2 lines exactly I want the last three lines exactly like this easily we can display by using tail for example I want a tail I want tail - two names one yes your answer correct you are expecting last two lines from names one and big file so what you are expecting big file last two lines names one last two lines first names one will be displayed and you observe tail - two names one big file see tail option use invalid context is nothing but go to may mane and tail and what exactly tail operations you can observe - N or - - lines output the last K lines so I fun and already user yet but you can sew tail one command - to supporting no doubt in that but whereas you are providing second file whereas you are providing second file and in value so that time you can apply even lines also - lines also so whenever we are using that I for - lines also so it is not same head level - two names one big file yes perfect but same command tail is enabled to that time we are going to filters is nothing but pipes we need to use here how to implement that pipe we can observe pipe is a simple command means pipe symbol first I am writing head - 6 big file yes pipe symbol tail - 3 as you expected first 6 lines from big file in that last three lines from big file 4 5 6 so 6 filtering into tail - 3 like this we can apply for example head - 5 big file good pipe symbol tail - 1 it is displaying the last that means of 5th line because you provided fifth in this fifth and last day - one like this head detail cooperation is going on now head and tail after some more filters available actually head and a tail we are calling as line filters using pipes also we can able to work you want to redirect this output to another file and you can redirect to my file if I hit the return key this output is storing in my file or my fi so in that file my line X output will be stored already this in the previous video session explained very clearly regarding redirections will observe NL the next command is NL what is NL numbered line labs are the manual pages man ll number lines of files if it is as normal file how to add a number simple option simple syntax available we'll observe so if you open any file for example I am opening one file it contains text I want to add line numbers as a prefix the term we are adding NL names it is a simple command to add line numbers as prefix to existing lines man and lobster NL same it is giving number lines of file NL option file name and you want to redirect this data also we can redirect if I hit the return key we know what happened so this data I want to change to permanently to another file yes in names to line numbers permanently added like this redirections we can use NL simple use it uses is numbering lines means adding line numbers as a prefix to the existing lines next one Cu T cut what is the cut command duty it is going to cut the data so Cu T cut particular lines but to clear characters we want to cut remove sections from each line of files generally in database time when we are writing queries we are applying on rolls table row you want to bring the data column wise we can go for the cut cut to option file name print selected - B bytes characters de limiters and fields so here I want to show you one file first the file is cat the EMP one table already created so field1 field2 field3 field for between field to field i entered a tab so when you are giving tab it is taking as a separate field means column so I want to display cut - if I want only third field from which file EMP file and that only salary free lam display I want for example names means 2 comma 3 and names and their salaries for example you want to bring 1 comma 3 only ID as well as salary and 1 - 3 is nothing but range range means from - 2 so it is playing 1st 2nd 3rd like this cut is a powerful filter which is displaying only selected fields not only that for example I am going to show you cat NIT there is a file available or cat MIT ok I will use this MIT file now cat MIT simple command cut - C 1 comma 2 3 4 5 6 7 I am using and I said MIT it is displaying character 1 means H and character 7 means m hm if I press the range of that it is displaying hello m so like this a perfect output is giving cut always cutting the characters whatever we required it is very useful for database programmers to bring the data only field wise next is paste what is paste merging of files will observe practically merge lines of files paste option file name what are the options available main important - s - - serial now whenever these options available Q you can press come out I am opening a few files cat 1 and cat - now paste and 1 - if I press ENTER it is merging these two files observe it is displaying by default - parallely side by side if you are giving - s it is displaying C really merge lines of files simply pasty is doing just a merging of files nothing else after paste will move to a new filter that is sought sorting the data how we are going to sort the data we can see for example s what is sought and let me go to manual section sort line of x-files sort option filename and it is giving always a particular bit history order also it is giving - d and several options ignore case line number means geomatics wat also available several options month assad and a numeric shot random as well as a reverse so several options available and check next one is merging output and will store the data in separate file and I will show you these options first cat names general one simple I am applying for better understanding here only names so it is perfectly sorted second file data first file data that one and second file data this right now for example sort - or yes reverse it is sorting all the files in reverse order now we are going to see another one SOT - n means numeric shot names one names one contains numerical data it is displaying in your numerical order perfectly not alphabets level now eyghon are a numeric reverse order so this is sort duty for example in sort area now I am going to sort two files means I am sorting MIT and another file is names and I am giving - M much just emerging if already sorted data available it is place that one if already sorted data not available just it will merge it won't sort just sorted so sort you want to see perfectly then I am using - oh is nothing but output output must be in result file so it is doing this command MIT names file sorting perfectly the output is storing in result file and output is not coming on the standard output device now the perfect output available in result file kat result so result file contains a complete data so information available like this so this is sort sort is a powerful filter which is sorting lines of text files next one TR TR is nothing but translate what exactly meaning of translate or delete characters for example lowercase characters I want to convert into uppercase numbers I want to convert into special characters special characters I want to convert into alphabets any kind of translation we can do main important option - D it is deleting characters from set one and observe practically what a TR is doing let me cat name simple one these names just TR wherever yes available capital s the same capital S I am converting into capital in and I am giving names perfectly so wherever available capital s it is converted into capital n now this data are temporary actually I want to permanent yes you can use redirections names too now whatever names to contains it is a permanent sorted it means converted data all small capital is converted into capital n right let me capital name sorry names now Smith scott raja vailable TR I am doing small a to Z good and I am giving capital A to Z and I am displaying names simply all lowercase characters I am converting into uppercase characters it is also redirection you can use for permanent now again I am using cat names ste are wherever lowercase Vogel's available I am converting into uppercase one letter that is you that's all and I said the names wherever lowercase o Wells available it is converted into capital u it is also temporary if you want to redirect redirect it you can make per a minute that so this is translate translate I am applying on tables for example there is a table available TR I want to change 0 to 9 wherever 0 to 9 characters available or for example 0 available the 0 character I am converting into 5 and I said the particular table name perfectly converted so this is a translate real uses in a live environment for example already cat the EMP available in this EMP - D delete I want to remove wherever 0 to 9 available from EMP file symbolized EMP table wherever number available no number displayed because I Fundy means a delayed so like this translate converting special characters also for example cat EMP I want to translate wherever a e i o u available ovince i want to convert into simply dollar and EMP simple and wherever available oval vowels converted into dollar so this is the manner translate command we can use redirection means use redirection operator same output you can send to another file by using new file any file name you can apply new file name you can say or volt file name you can say you can apply right after TR we can see another command that is T GG is nothing but multi redirection Allah manned multi redirection 'l filter we are calling what is the use of this multi-directional yeah man twe multi-directional read from standard input means keyboard and write standard output means file or monitor and files anyone twe option file name once it is append ignore help may these are the main up and I will show you most important one so TW generally Cal command output we know why I am calling T is a multi redirection 'l example already we did in the past video redirections it is a multi redirection one copy it is displaying on the screen means standard output device another copy it is sending to file or files means at a time it is doing multiple redirections now cal only on the screen it displays is a Cal now the same calendar Cal pipe symbol means this command output I am redirecting soon next command T EE and file M I am providing Oct 1 6 if I hit the return key one copy on my screen another copy available in my file means same output redirected to more than one that is called a multi redirection one output is here another output is here this is a multi redirections so TW is a powerful filter for example cat ok WC LS cat MIT simply MIT fella use cat MIT pipe symbol WC - L we know already several times we did now again this one pipe symbol I am using twe I said the lines one copy on the screen another copy in this file available this is multi redirection real uses of the multi redirection next filter we can see said stream editor what is stream editor reality duty stream editor for filtering and transforming text is a syntax little differently available sed option script only if no other script input file so several options available set is a stream editor now if you are coming to options and second one is expression third one is copy like this several options available a few options will observe practically I am clearing first I am taking cat names one or cat a big file anyone why I am selecting only these files means your line numbers prefix available so perfect output purpose I selected now in this file for example yes didi to cue cue means quit and I am giving big file first two lines disp laughter it will be quit for example s ud3 Q and I said names one yes like this it is going to be display particular lines but took your lines means s you D - n I want a second line from big file yes I want not only second line I want second line and a fifth line from big file like this particular lines also we can display so this stream editor doing several actions 3-meter is a bigger one substitution also we can do so stream a little more realities also we can observe in upcoming video next I am going to another powerful filter family grab EF grab Ygritte group means globally such for regular expressions F group means fast globally such for regular expressions e group means if were extended globally such for regular expressions almost all it is a searching family searching a filter family in this grip features F group of features is equal to e grip at least first grep we are going to understand first grabbed man grep manual pages I am display print lines matching a pattern grep options a pattern file name and several options available big list of options available maximum options will try with practically now once we are entering into here group level I am taking a simple file the file is LS cat I created courses yes it is a file available cat courses file I am taking you also create one courses file like this for a better output once I created this courses file I am applying all my group related options on this file first grab I am going to find UNIX string in courses file you observe are not in courses file UNIX two times available one is starting all lowercase UNIX another one is starting you remaining all lowercase if I hit the return key only one line displayed because unikz capital you if you are if you are going to display two lines - I ignore case what is the first unix line number I want to see and those lines how many available counting also we can display then you want to apply ni ni is nothing but and a number of lines with ignore case first line fourth line first line also unix fourth line also unix but character wise there is a difference available UNIX UNIX now count also I said to now you want to see this count also we can line number does not require me to leave it count only one is two for example grab I want to find out it is courses gap is a filter it is string courses file name so I am finding all the lines I want to display all the lines wherever it is string available that is as per my requirement I entered but UNIX understanding group is filter it is string is file one courses file - so whenever it is creating that if I hit the return key and it is showing like this is already filename available it is text file so remaining three lines courses perfectly displayed because it is it is it it piece now if I try to remove that RM is already file I created remote now same command I'm running observe please no such file or directory previously perfectly output game means group it is treating as a filter it is string easy is file one and courses is file - to avoid this ambiguity you must mention string should II within the double quotation what is a perfect filter command means grab is grep is yes now without any kind of controversy perfectly displayed it is true so whenever you are giving a string it should be it must be within the double quotes now I am providing some more graph I am giving you Nick's string a string it displays all the filenames wherever units string available you need that means it displays not only file names now file name plus as well as the string wherever available that line also displaying no no I want only file names I want only file names I want to display so that time we are using sorry small L capital L it displays all the files wherever string not existed or strings not existed small L it displays all the files wherever strings existed so this is crap grep level some more we'll observe some anchors available here mainly two anchors one is a cap it always matches starting characters another one is dollar it always matches ending characters and it matches even patterns also how it is a matching pattern first patterns we can see then I will go to anchor spot first grab double quotation and I am giving inside starting is I said for example see a e IOU and I said ll double quotation close courses it displays all the lines which are call cell sill means starting C middle any letter that one and ending must be double L you want to display these line numbers yes - n perfect you want to see these line numbers including ignore case capital letters or not that same letters I want to change C as B yes available capital as well as small letters like this line numbers are displaying so different different characters but starting up the uppercase you can you can remove I ignore case and it displays only the line lower case like this different patterns also we can able to display next and I am writing grab quotation start I want to display you cap and I said courses if I press ENTER it displays out only one life UNIX lower case y not displayed actually graph courses level UNIX is available and cat courses and lower case u available yes and a command while you are going to type you check it and you need to use yes perfect always our anchor means special character must be wildcard must first now I'm going to provide here - I ignore case I want to provide here almost on every line I want to view means line number now for example I am providing Java if I am removing - I know lines will be displayed but you are having one line why it is not displaying because it is a capital letter capital J you can say yes perfect Java is a loop language so patterns perfect it is matching or not we need to check it for example I want to use double quotation and inside available and these are removed - so cap I kept Here I am writing a e i o u and if i hit the return key it displays all the lines which are starting with lowercase ovals only one u available one you displayed for example - i yes your answer correct capital u small u now i you said and inside i am changing starting be starting c and for example starting j like that i want so if i hit the return key abs are no maximum lines displayed which are starting with uppercase lowercase b upper case lower case c uppercase lowercase J upper case lower case o upper case lower case u all the lines displayed except a dotnet because starting with the Tata special character that one also we can display now so grep level we observed only cap now cap related another one we can see and I am removing this ignore case sense I provided for example like this I said a e io you there is a sense a e iy you ovals if I hit the return key it displays all the lines which are starting with lower case and we need to understand two caps available when two caps availability is working in verse 11 in verse in the sense it displays all the lines which are not starting with lowercase ovals so not starting with means all others so like this whenever you are using double it is working as inverse now next one now here only I want to apply the previous now I did like this you is displaying only the lines which are not starting with these uppercase and lowercase characters as I said dot and Raj also and you don't want Raj means you can use our s as you expected onset now grep level taller available what is the dollar uses grab double quotation start a dollar double quotation close courses it will displace all the lines from the courses the line which is ending with lowercase e letter I want to see the client number definite life on n I want to see uppercase as well as a lowercase sure so like this the lines which are ending with now count also we can use definitely yes now I am writing grab double quotation start I am saying here AE IOU yes and double quotation close inside dollar I said after that I am providing file name courses enter yes you're expecting correct answer it displays all the lines which are ending with a Yi I vote you only lowercase ovals yes and lowercase as well as uppercase I am changing one letter s also and I am giving - I also yes observe only several lines now we want to see that and what are the line numbers available several line numbers and how many line numbers available total I want to view that yes C and Phi line seven so graph is one outstanding filter which is doing perfect searching any string that line completed displays now here only available some kind of empty lines I want to display for example I said cat NIT you remember are not iPhone and already explained line numbers three empty one data line available and if you are giving blank also explained already blank line on a line number getting using my grep command I can try to perform action on this one and I am giving cap dollar yes and I said NIT if I hit the return key it displays only blank lines no data lines and how many blank lines available you want to see count three blank lines available how many available line numbers also you want to see perfect two three four blank lines no I don't want blank lines I want the data lines that time you can use and fee it is working inverse only data lines it is place so crap is that much powerful filter displaying only blank lines only data lines like this there is no end point for the grip when you are coming to F grip as I said fast quicker compared to grip performance-wise quick remaining all features same if you are applying F game and you are writing one UNIX string one line x string one Java string from only courses file perfect I want to check from multiple files courses as well as another file available MIT for example in these two files I want to check our UNIX while I want to check yes and UNIX such file or directory not available if available searching not a wire is not available displaying so for example file - I am giving MIT file available yes but in that file is UNIX string is not there line X Wing is not there and as well as Java string is not there okay I want to append in front of you MIT I am saying UNIX is king of all operating systems one line added same command I am executing in front of you whatever I implemented it just hit the return key yes UNIX is king of all operating systems like this F grip is only quick but excellent features like grab finally II grabbed it is extended means grapa features plus F grip of features is equal to e grip most strongest ik filter in entire UNIX operating system is egress it is executing for example already is shown to you grep related now you know what is this so displaying only data lines yes now I want to execute the same command D grip perfect so he grip is equal to grab a place and I want to execute a PF grab related yes this is F I am removing and you adding e perfectly so undoubtedly we can say one point e grep is equal to grab a place F grab thank you for watching my videos for more videos catch me in youtube.com slash narration
Info
Channel: Naresh i Technologies
Views: 135,392
Rating: undefined out of 5
Keywords: UNIX, Subba Raju, UNIX File Permissions, Hands on UNIX Training, Online Unix Traininig, UNIX Tutorial Videos, UNIX Overview, UNIX Interview Questions, Unix Filters, Filters, UNIX Tutorial, unix filters and commands, filters and commands, unix system filters, linux filters, Filters in unix, filters unix, filters in linux, what is filter in unix, what is filter in linux, simple filters in unix
Id: 0noUlKxs5eQ
Channel Id: undefined
Length: 43min 38sec (2618 seconds)
Published: Fri Oct 14 2016
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.