Hi,
I've been searching for a quick way to do this with sed, but to no avail.
I have a file containing a long series of (windows) file paths that are separated by the pattern '@'. I would like to extract each file path so that I can later assign a variable to each path.
Here is the file:
C:\Documents and Settings\My Documents\MATLAB@C:\Documents and Settings\My Documents\MATLAB\a.zip@C:\Documents and Settings\My Documents\MATLAB\f.bhdr@C:\Documents and Settings\My Documents\MATLAB\f_000.bshort@C:\Documents and Settings\My Documents\MATLAB\f_000.hdr@C:\Documents and Settings\My Documents\MATLAB\f_004.bshort@C:\Documents and Settings\My Documents\MATLAB\f_004.hdr@
C:\Documents and Settings\My Documents\MATLAB@C:\Documents and Settings\My Documents\MATLAB\test.nii.gz@C:\Documents and Settings\My Documents\MATLAB\test.zip@C:\Documents and Settings\My Documents\MATLAB\test2.txt@C:\Documents and Settings\My Documents\MATLAB\tmp.tiff@
And I would like the output to be:
C:\Documents and Settings\My Documents\MATLAB
C:\Documents and Settings\My Documents\MATLAB\a.zip
C:\Documents and Settings\My Documents\MATLAB\f.bhdr
C:\Documents and Settings\My Documents\MATLAB\f_000.bshort
C:\Documents and Settings\My Documents\MATLAB\f_000.hdr
C:\Documents and Settings\My Documents\MATLAB\f_004.bshort
C:\Documents and Settings\My Documents\MATLAB\f_004.hdr
C:\Documents and Settings\My Documents\MATLAB
C:\Documents and Settings\My Documents\MATLAB\test.nii.gz
C:\Documents and Settings\My Documents\MATLAB\test.zip
C:\Documents and Settings\My Documents\MATLAB\test2.txt
C:\Documents and Settings\My Documents\MATLAB\tmp.tiff
I can sort-of get there with something like:
sed 's,^\(.*@\)\?\([^@]*\),\1,'
in a loop or something like that, but I was hoping for a simpler (a one-liner maybe?) or a more elegant solution. If anyone can help, I would greatly appreciate it. Thanks in advance!