I have a text file where each line has the format like this...
25126 Akers, David
And I'm needing to put it in a format like this to insert into a database...
25126;Akers, David;Only problem is there might be some with names having spaces like...
25257 Ah You, C.J.I was told I should use grep but I'm not sure how to go about doing it.
41 Answer
grep is not suitable for such a task, because it is a search tool, but if I understand correctly the problem, you can use sed, as in the following example:
sed 's/^\([0-9]\+\) \(.*\)$/\1;\2;/' input-file >output-fileTo preventively check that all lines conform to the above pattern, run the following command
sed -n '/^\([0-9]\+\) \(.*\)$/!p' input-filethat should return nothing.
0