I'm trying to create a shell script called sv that will prepend to a file, but the solution I'm using seems to only be good for one use, and them the temporary file is deleted. Is there a way I can make a shell script that will be go to use over and over?
Here's the questions: "Suppose we wish to maintain a list of all the dates when we logged on to our UNIX system. It would be easy to do this by adding the following to the .login file: date >> logdates Unfortunately, the latest date comes at the end of file logdates. I want it at the front; that is, the file should contain login dates from latest to earliest. Write a C shell script sv that will be used as follows: date | sv logdates (This way, the script is quite general, and I can use it for other cases when I want to add things to the front of a file.)"
Here's the script I've come up with:
"#!/bin/sh
cat - logdates /tmp/out && mv /tmp/out logdates"
This will work once, when I try again the system tells me that /tmp/out doesn't exist.
Does anyone have any suggestions?
Thank you!