I am using cygwin and have a lot of files in which I want to convert tabs to spaces (four spaces per tab) and remove all space characters that exist at end of line. Is there a utility for this in Linux?
sed -E 's/\t/ /g;s/\s*($)/\1/g' infile outfile
Each tab (
\t) is replaced by 4 spaces, and trailing spaces (actually, all whitespace characters up to the end of the line (
$) are removed. If you don't want the result in a new file, you can tell
sed to do the replacements inline (
sed -i -E 's/\t/ /g;s/\s*($)/\1/g' file
In a lot of files? No prob:
sed -i -E 's/\t/ /g;s/\s*($)/\1/g' *
(just pass a "mask", like
*.txt or whatever files should be matched).
You can get
sed from your distro's package management, e.g.
apt install sed.