Bulk Modify the delimiter of the file, you can use the FS and OFS commands
Fs:field Separator, Field delimiter
Ofs:out of field Separator, output fields delimiter
Suppose there is such a file file1.txt, which reads as follows:
As you can see, the file1 delimiter is very long and consists of more than one space character, so we need to unify the delimiter first and enter the command:
Awk-f "" ' {if ($1~/^16/) print $1,$2,$3,$4} ' file1.txt > File2.txt
Generate file2.txt, such as slices:
The delimiter is unified to a single space, then the delimiter is uniformly modified to a comma ",", enter the command:
awk ' begin{fs= ' "; ofs=", "} {print $1,$2,$3,$4} ' file2.txt > File3.txt
The resulting file file3.txt is as follows:
If you want to change the delimiter to a colon, simply change the ofs= "," to ofs= ":"
Linux: Bulk Modify Separators (awk, BEGIN, FS, OFS, print commands)