Sruthy, with her 10+ years of experience, is a dynamic professional who seamlessly blends her creative soul with technical prowess. With a Technical Degree in Graphics Design and Communications and a Bachelor’s Degree in Electronics and Communication, she brings a unique combination of artistic flair…
learn Cut Command in Unix with Simple and Practical Examples:
Unix provides a number of filter commands that can be used for processing flat file databases. These filter commands can be chained together to perform a series of operations with a single command.
A flat file database is a file that contains a table of records, each of which contains fields separated by delimiter characters. In such a database, there is no structural relationship between records, and there is no structure for indexing.
The cut command extracts a given number of characters or columns from a file. For cutting a certain number of columns it is important to specify the delimiter. A delimiter specifies how the columns are separated in a text file
Example: Number of spaces, tabs or other special characters.
Syntax:
cut [options] [file]
The cut command supports a number of options for processing different record formats. For fixed width fields, the -c option is used.
$ cut -c 5-10 file1
This command will extract characters 5 to 10 from each line.
For delimiter separated fields, the -d option is used. The default delimiter is the tab character.
$ cut -d “,” -f 2,6 file1
This command will extract the second and sixth field from each line, using the ‘,’ character as the delimiter.
Two powerful commands for processing the databases are ‘cut’ and ‘paste’. The cut command in Unix is used to extract specified parts of each line in a file, and the paste command is used to insert the contents of one file into another line by line.
Learn Unix Cat Command with Examples: The cat command is perhaps the most commonly used Unix command. It is derived from catenate – which describes the process of connecting things. The cat command is a filter that can be used for multiple purposes: Display the contents of text files. Copy text…
Introduction to Find Command in Unix: Search files and directories with Unix Find File Command The Unix find command is a powerful utility to search for files or directories. The search can be based on different criteria, and the matching files can be run through defined actions. This command recursively…
Learn Tar Command in Unix with practical Examples: The primary function of the Unix tar command is to create backups. It is used to create a ‘tape archive’ of a directory tree, that could be backed up and restored from a tape-based storage device. The term ‘tar’ also refers to the…
Learn ls Command in Unix with examples: The Ls command is used to get a list of files and directories. Options can be used to get additional information about the files. Know ls command syntax and options with practical examples and output. ls Command in Unix with Examples ls Syntax: ls…
Learn Grep Command in Unix with Practical Examples: Grep command in Unix/Linux is the short form of ‘global search for the regular expression’. The grep command is a filter that is used to search for lines matching a specified pattern and print the matching lines to standard output. Grep Command…
Learn Unix Sort Command with Examples: The Unix sort command is a simple command that can be used to rearrange the contents of text files line by line. The command is a filter command that sorts the input text and prints the result to stdout. By default, sorting is done…
Overview of Unix Filters Text Processing Utilities: In this tutorial, we will learn about filters and work with various filter commands. Filters are commands that read input from stdin and write output to stdout. By default, when using a shell terminal, the stdin is from the keyboard, and the stdout is…
In this tutorial, you will learn different basic and advanced Unix Commands. Unix commands are inbuilt programs that can be invoked in multiple ways. Here, we will work with these commands interactively from a Unix terminal. A Unix terminal is a graphical program that provides a command-line interface using a…