Modifying text file with "one command line" SED command...
I have a text file like:
this is test 1234 wow
this is test 3456 wow
this is test 5463 wow
I need to bring it to such format:
As you see, first and last strings should be deleted, each string should be truncated to one substring value (numeric), each result string should end with comma (",") except the last one.
Question: Is it possible to do without CUT/AWK constructions? Just with SED ?
the following will remove everything except the digits:
cat oldfile | sed 's/[^0-9]//g' <oldfile >newfile
Adding commas before all the newlines except one is more involved, I'll come back to the thread later if I get a few minutes to work out exactly how to get the result you want.
This may be rough (rough is a speciality of mine), and it uses grep to exclude the start and end label tags. But it works..
's/$/,/' - appends "," to the end of the line
'$s/.$// - removes last character from the stream (the final ",")
This will do what you want except remove the last comma - not sure it can be done in a single sed command:
|All times are GMT -5. The time now is 03:32 AM.|