- Kali Linux Tutorial
- Kali Linux - Home
- Installation & Configuration
- Information Gathering Tools
- Vulnerability Analyses Tools
- Kali Linux - Wireless Attacks
- Website Penetration Testing
- Kali Linux - Exploitation Tools
- Kali Linux - Forensics Tools
- Kali Linux - Social Engineering
- Kali Linux - Stressing Tools
- Kali Linux - Sniffing & Spoofing
- Kali Linux - Password Cracking Tools
- Kali Linux - Maintaining Access
- Kali Linux - Reverse Engineering
- Kali Linux - Reporting Tools
- Kali Linux Useful Resources
- Kali Linux - Quick Guide
- Kali Linux - Useful Resources
- Kali Linux - Discussion
How to remove sections from each line of files in the Linux system?n
In this article, we will learn to remove sections from each line of files in the Linux/Unix operating system.
To remove selected parts of lines from each FILE, we use the cut command in the Linux system.
The cut command is used to remove and print the selected section of each FILE in the Linux operating system using a terminal. It is also used to cut the selected parts of a line by byte position, character, and field. It is also been ported to the IBM i operating system.
The general syntax of the cut command is as follows
cut OPTION... [FILE]...
Brief description of options available in the cut command.
|Sr.No.||Option & Description|
Select only specifies bytes
Select only specifies characters
Specify delimiter instead of TAB
Select only specified fields, and display any line that without delimiter, unless the -s option is specified
With option -b, do not split multibyte characters
Complement the set of selected bytes, characters, or fields
|7||-z, --zero -terminated|
Line delimiter is NULL, not newline
Display this help and exit
Output version information and exit
To cut the specifies bytes from every column without range, we use -b or --byte option with the cut command in the Linux system.
Here, we will cut only two bytes from every column from a file as shown below.
vikash@tutorialspoint: ~/shadow$ cut -b 1,2 text1.txt ar ry sa st to ut va vikash@tutorialspoint− ~/shadow$
To cut the specified character from every column, we use -c or --characters option with the cut command in the Linux system.
Here, we will cut only the first, second, and fourth characters from every column from a file as shown below.
vikash@tutorialspoint − ~/shadow$ cut -c 1,2,4 text1.txt ara ryn sa stv to uta vah vikash@tutorialspoint − ~/shadow$
To cut the specified range character from each column, we need to specify range with -c option as shown below.
vikash@tutorialspoint −~/shadow$ cut -c 2-4 text1.txt rya yan am tev om tka ash
In the above example, we cut the second to fourth characters from each column from a file in the Linux system.
To check more information about the cut command, we use the --help option with the cut command as shown below.
$ cut --help
To check version information of the cut command, we use the --version option with the cut command as shown below.
$ cut --version
- Related Articles
- How to compare two sorted files line by line in the Linux system?
- How to remove files and directories in the Linux operating system using the terminal?\n
- How to merge lines of files in the Linux system?
- How to swap two files in Linux command line?
- Remove Line Endings From a File on Linux
- Remove the First Line of a Text File in Linux
- How to Protect Files and Directories from Deleting in Linux
- How to wrap each input line to fit in specified width in Linux?
- How to create links between files in the Linux?
- Soft-Delete Files from the Terminal on Linux
- How to download APK files from Google Play Store on Linux
- Linking to Files in Linux
- How to Add a String After Each Line in a File in Linux?
- How to sort lines of text files in Linux?\n
- How to flushes file system buffers in the Linux operating system?