I have a text file that has the following format:
characters(that I want to keep) (space) characters(that I want to remove)
So for example:
Following up on the answer by @Steve, if you want to use a different separator (eg. comma), you can specify it using -F. This will be useful if you want the content of each line upto the first comma, such as when trying to read the value of the first field in a csv file.
$ awk -F "," '{print $1}' text1.txt > text2.txt