Often you may want to use Bash to remove the first column from a file.
You can use the following syntax with the cut command to do so:
cut -d " " -f2- players.txt > players_new.txt
This particular example removes the first column from the text file named players.txt and saves the results to a new text file named players_new.txt.
Here is what the various commands do
- cut: Specifies sections from each line in the file to return
- -d ” “: Specifies that a single space should be used as a delimiter
- -f2-: Specifies that column 2 through all remaining columns should be returned
- >: Specifies the name of an output file to save results to
Note that this particular example uses a single space as a delimiter, but you could specify a different delimiter to use if you’d like.
For example, if you’re working with a CSV file then you could use -d “,” to specify that a comma should be used as a delimiter instead.
The following example shows how to use this syntax in practice.
Example: How to Use Bash to Remove First Column from File
Suppose that we have a file named players.txt that contains information about various basketball players.
We can use the cat command to view the contents of this file:

Suppose that we would like to remove the first column (the “team” column) from the file and save the results to a new file.
We can use the following syntax to do so:
cut -d " " -f2- players.txt > players_new.txt
The following screenshot shows how to use this syntax in practice:

Notice that when we use the cat command to view the contents of the new file named players_new.txt we can see that it contains the same contents as the original file but the first column has been removed.
Feel free to use similar syntax with the cut command to remove the first column from your own file.
Related Tutorials
The following tutorials explain how to perform other common tasks in Bash:
Bash: How to Swap Two Columns in a File
Bash: How to Delete Duplicate Lines in File
Bash: How to Replace Specific Line in File
Bash: How to Replace All Occurrences of String in File
