by using above script i am able to remove the head and tail part from the input file and able to append the output to the output.txt but if i run it for second time the output is getting appended to the existing output file...i want to clear the content of the file before appending the output...how i can i acheive it ..?
I'd be highly surprised if that would NOT entirely overwrite output.txt , as >> is the redirection operator for appending. On the other hand, x won't be defined, as wc does not have a -1 option and your assignment statement will produce an error.