Linux Reader
Access files and folders on Ext, UFS, HFS, ReiserFS, or APFS file systems from Windows

Pew Pew madafakas!

Access files and folders on Ext, UFS, HFS, ReiserFS, or APFS file systems from Windows

Cut in Shell Script Examples

Here you will find out:

  • about Shell script cut
  • examples of script cut
  • when DiskInternals can help you

Are you ready? Let's read!

About Shell Script Cut

The Command is cut in shell script used to split text and select the necessary parts, followed by writing to standard output. This utility is part of GNU Coreutils, so it is by default available on all Linux distributions.

The basic syntax is as follows:

If necessary, you can specify not one file, but several. For more details, enter the command 'cut --help' and you will learn much more.

-d option - delimiter

-d (--delimiter = DELIM) - this function allows you to set your own separator instead of the standard TAB. This option is not found alone, it is recommended to use it with -f (--fields = LIST) - fields for cutting.

Example: there is a CSV file called people.csv.

You need to cut the first field:

If you need to cut several fields, you just need a comma:

Nothing complicated, just utmost care is needed.

-c option - cut by character

-c (--characters = LIST) - an option that allows you to cut a specific character or several of them. This function is superior to working with bytes, as it is easier to use and does not depend on the number of bytes.

An example would be with the symbol ♣

You can specify a specific range of characters, separated by dashes, or only selected characters, separated by commas. As you can see, with a single command, you can perform many actions.

-b option - cut by byte position

-b (--bytes = LIST) - a function that allows cutting by byte number, set, or range of bytes.

There can be a huge number of examples; here are the most common cases of using this function.

The same command with ranges

A command for cutting by bytes:

  • From 1 byte to the end:
  • From 1 byte to 3 bytes:

By analogy, you can apply your values.

- complement - cut by complement

This function is slightly different from the others in its meaning.

--complement - specifies the characters, bytes, or fields that will remain in the file, and everything else will be cut.

This option can be used in conjunction with the -f or -c options.

For example:

Another example:

These functions are very useful when working with large text documents. Saving time also plays an important role.

Want to use Linux files on Windows?

DiskInternals Linux Reader is a unique, unparalleled application that allows you to get files from Linux to Windows. This is especially useful when you are using a virtual machine or dual boot. The application is available in a trial version at no cost with the ability to view files. DiskInternals Linux Reader gives you Windows access to various Linux file systems, such as HFS, Ext2/Ext3/Ext4, ReiserFS, and others. The program professionally moves files without unnecessary options, without advertising and other things.

If you want more features, then there is no need to look for something else - you can simply update the program to a more advanced version and use the already large arsenal of options. If you are quite comfortable with the standard set of actions in the DiskInternals Linux Reader, this is great; use it and be satisfied.

Related articles

FREE DOWNLOADVer 4.13, WinUpgrade to PROFrom $29.95

Please rate this article.