1 / 12

In the last class,

In the last class,. Filters and delimiters The sample database pr command head and tail commands cut and paste commands. paste: pasting file (contd.,). We can specify one or more delimiters with -d paste -d “|” cutlist1 cutlist2 Where each field will be separated by the delimiter |.

terresa
Download Presentation

In the last class,

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. In the last class, • Filters and delimiters • The sample database • pr command • head and tail commands • cut and paste commands

  2. paste: pasting file (contd.,) • We can specify one or more delimiters with -d paste -d “|” cutlist1 cutlist2 Where each field will be separated by the delimiter |

  3. Joining lines (-s) Let us consider that the file address book contains the details of three persons cat addressbook paste -s addressbook -to print in one single line paste -s -d ”| | \n” addressbook -are used in a circular manner

  4. Sort : ordering a file • Sorting is the ordering of data in ascending or descending sequence. The sort command orders a file and by default, the entire line is sorted Example: sort shortlist

  5. Sort options -tchar uses delimiter char to identify fields -k n sorts on nth field -k m,n starts sort on mth field and ends sort on nth field -k m.n starts sort on nth column of mth field -u removes repeated lines

  6. -n sorts numerically -r reverses sort order -f folds lowercase to equivalent uppercase -m list merges sorted files in list -c checks if file is sorted -o flname places output in file flname

  7. sort –t“|” –k 2 shortlist sort –t”|” –r –k 2 shortlist or sort –t”|” –k 2r shortlist sort –t”|” –k 3,3 –k 2,2 shortlist sort –t”|” –k 5.7,5.8 shortlist sort –n numfile

  8. uniq command Locate repeated and non-repeated lines cat dept.lst uniq dept.lst sort : dept.lst | uniq - uniqlist Selecting the nonrepeated lines (-u) Selecting the duplicate lines (-d) Counting frequency of occurrence (-c)

  9. tr command Manipulates the individual characters in a line. It translates characters using one or two compact expressions tr options expn1 expn2 standard input It takes input only from standard input, it doesn’t take a filename as argument tr ‘|/’ ‘~-’ < emp.lst | head –n 3

  10. exp1=‘|/’ ; exp2=‘~-’ tr “$exp1” “$exp2” < emp.lst Changing case of text head –n 3 emp.lst | tr ‘[a-z]’ ‘[A-Z]’ Deleting charecters (-d) Compressing multiple consecutive charecters (-s) Complementing values of expression (-c) Using ASCII octal values and escape sequences

  11. Summary • Filters and delimiters • pr command • head and tail command • cut and paste command • sort command • uniq command • tr command

  12. THANK YOU

More Related