Adding ";" (semi-colon) in each space between hour and filename
Since there are no other space characters in your list, you can use sed
to replace the first space character in each line with a semicolon:
sed 's/ /;/' file
This can be done with awk
or sed
:
awk '{print $1";"$2}' file
awk -F ' ' '{print $1,$2}' OFS=";" file
sed 's| |;|' file
The first awk
command prints a ;
between the first and second column and the second converts the space delimiter to a ;
. The sed
command simply replaces the space with a ;
. To edit the file in place with sed
:
sed -i 's| |;|' file
With awk
, assuming that the version is 4.1.0 or later:
awk -i inplace '{print $1";"$2}' file
awk -i inplace -F ' ' '{print $1,$2}' OFS=";" filename
Had similar problem at an email server, just put this list in a file01.txt
text file, then apply following command:
cat file01.txt | sed 's/[ \t]/;/g' > file02.txt