I have a file that looks like this
.../proj_1/file1.txt 8 2018-03-14 07:46:01
.../proj_1/file3.txt 3 2018-03-14 07:47:01
.../proj_1/file2.txt 10 2018-03-14 07:45:01
.../file1.txt 2 2018-03-14 07:50:01
and I'd like to extract date and time which is in the 3. and 4. column and save it into a variable. (dir_path is the name of the directory and source_file is the file I described above)
variable=$(grep "$dir_path/.*" source_file | grep -v "$dir_path/.*/" | awk '/[0-9]/{print ($3 $4)}')
My desired output is
2018-03-14 07:46:00
2018-03-14 07:47:00
2018-03-14 07:45:01
But with this code, the output looks like this
2018-03-1407:46:00
2018-03-1407:47:00
2018-03-1407:45:01
How do I put the space in between the date and time? Is it even possible? If I but a space into the awk expression, the the time and date is saved in separate elements which is not what I want.
Thank you for any help!