|
Sed – how do I save output to file with filename from content of another file?
My employer issues pdf files with everyone’s work schedules. I copy the content and save it as plain text in a file called “unformatted” (hope to be able to automate this step someday). I’m working on a SED script that reduces “unformatted” to only display what I want to see and saves the result in a file I’ve named “formatted”. After that I have to manually copy “formatted” and save it with that days date as a filename e.g. “2011-02-25” or whatever day is scheduled in the pdf, for use on a mobile device (Nokia N900). I noticed that the date occurs on certain lines in the file so I added a line like:
sed -n 's/^Date: \(201[1-9]\)\/\([0-1][0-9]\)\/\([0-3][0-9]\).*/\1-\2-\3/p' < unformatted >theDate
That creates a file “theDate” with the date in it that I wish to use as the filename for this particular instance. So I would like to skip the file “formatted” all together and have the sed- script write to a new file using the content of “theDate” as a filename, but how do I make that happen?
And of course it would be more elegant if I could skip the intermediate “theDate” file as well….
|