
- 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 converts tabs to spaces in the Linux system?
While working with files, sometimes a situation occurs that a file contains many tabs and the requirement is a file in which no tabs but with space. In this case, if a file is quite simple then work is easy but if we are dealing with a long file then it’s very tough work.
To convert tabs to spaces, we use the expand command in the Linux system. If file is not given then the expand command read standard input.
Syntax
The general syntax of the expand command as follows −
expand [OPTION]... [FILE]...
Brief description of options available in the expand command.
Sr.No. | Option & Description |
---|---|
1 | -i, --initial Don’t convert tabs after non blanks |
2 | -t, --tabs=N Have tabs N characters apart, not eight |
3 | -t, --tabs=LIST Use commas separated list of tab positions |
4 | --help Displays a help message and then exits. |
5 | --version It gives info about the version and then exits. |
To converts each tab into specified space in the Linux system, we use the -t or --tab option with the expand command.
First, we need to create a file using the cat command in which tabs contain.
$ cat >text.txt Hey, welcome to tutorialspoint... ^C
Then after to converts these tabs into space, we use the expand command as shown below.
$ expand –-tabs=1 text.txt Hey, welcome to tutorialspoint...
We have already seen the above example to converts tabs into spaces from files. To converts tabs into space from standard input, we use the expand command as shown below.
$ expand –-tabs=1 Hey, welcome to tutorialspoint... Hey, welcome to tutorialspoint...
To stop conversion after non blanks, we use the -i or --initial option with the expand command as shown below.
$ expand -i text.txt
Or
$ expand --initial text.txt
To check more information about the expand command, we use the --help option with the expand command as shown below.
$ expand --help
To check version information of the expand command, we use the --version option with the expand command as shown below.
$ expand --version
After executing the above command, in which version expand command is working is prompt.
- Related Articles
- How to expand tabs in string to multiple spaces in Python?
- How to strip spaces/tabs/newlines using Python regular expression?
- How to check if text is “empty” (spaces, tabs, newlines) in Python?
- How to flushes file system buffers in the Linux operating system?
- How to move jobs to the background in the Linux system?
- How to Improve Linux System Security
- How to iterate over a list of files with spaces in Linux?
- How to replace spaces in file names using bash script on Linux?
- How to merge lines of files in the Linux system?
- How to display the current working directory in the Linux system?
- How to handle tabs in Puppeteer?
- How to mount usb drive in a linux system
- How to Change or Set System Locales in Linux
- How to create key binds in the Linux system using the terminal?
- How to display the first part of the file in the Linux system?
