Hi there. New to the forum so hello.
I am currently studying a Computer Science degree and have some linux shell course work to do which is giving me some problems and would appreciate some help.
I am in the process of writing a script that takes 3 input files, sorts these files in alphabetical order and then outputs the last line of each file to another file in reverse alphabetical order.
I have written the code no problem and had it working fine but there are various checks that have to be done before it actually processes the files and creates the output file.
I have all but one check figured out and that is that for every temporary file used in the script a check must be done to make sure that it does not all ready exist in the working directory. If it does exist in the working directory then it adds a number to the file e.g. if my temp file is s.txt but all ready exists then the program should check to see s1.txt exists and so until it finds one that does not exist and uses it as the temp file.
I have various temp files which are: s1.txt, s2.txt, s3.txt, op1.txt, op2.txt, op3.txt, op4.txt and output.txt.
Also when the program has finished the process I would also like to remove all temp files and just leave the output.txt file in the directory. I am unsure of how to do this but some light may be shed once I find out how to do the first part.
Any help would be greatly appreciated. Thank you very much for reading.
