You can use the command sed to remove spaces from a file. The basic syntax for removing spaces from a file is:
sed 's/ //g' <input file> > <output file>
This command will take the input file, find all instances of spaces ( ) and replace them with nothing, effectively removing them, and write the output to the specified output file.
If you want to remove spaces at the beginning of each line, you can use the following command: