Unix Tutorial 14 : Text Processing Commands 1

Unix Filter Commands

  • grep: Find lines in stdin that match a pattern and print them to stdout.
  • sort: Sort the lines in stdin, and print the result to stdout.
  • uniq: Read from stdin and print unique (that are different from the adjacent line) to stdout.
  • cat: Read lines from stdin (and more files), and concatenate them to stdout.
  • more: Read lines from stdin, and provide a paginated view to stdout.
  • cut: Cut specified byte, character or field from each line of stdin and print to stdout.
  • paste: Read lines from stdin (and more files), and paste them together line-by-line to stdout.
  • head: Read the first few lines from stdin (and more files) and print them to stdout.
  • tail: Read the last few lines from stdin (and more files) and print them to stdout.
  • wc: Read from stdin, and print the number of newlines, words, and bytes to stdout.
  • tr: Translate or delete characters read from stdin and print to stdout.
Commandgrep - It is a command for pattern searching in a file and prints those lines containing that specified pattern. If the file name is not mentioned, grep searches in stdin.
Common Syntax$ grep [option] pattern [filename …]
Example$ grep ‘[A-M]’ file1
Prints those lines which contains capital letters in the range of A to M
Commandwc - It is a command to count the number of lines, words and characters in a file
Common Syntax$ wc [OPTION] ….[FILE]
Example$ cat file1
Hello
How do you do
$ wc file1
2 5 20 file1

No of lines-2
No of words-5
No of characters(bytes)-20
Commandmore - This command is used to display the page one screen at a time
Common Syntaxmore [options] file…
Example$ls -l | more
Will display long listing of files and directories one screen at a time
Commandpaste: this command is used to paste the contents of two files.
Common Syntax:paste [OPTION] ….[FILE]….
Example:paste file1 file2
This command will combine the contents of file1 and file2

Comments

Popular posts from this blog

Hive Tutorial 31 : Analytic Functions

Hive Tutorial 37 : Performance Tuning

How to change sqoop saved job parameters