Hi I am trying to write a bash script to add a line of text to the middle of a file.
The way I worked it out was to calculate the number of lines and divide by 2. The file I am using is called newfile and it just contains lines of data.
The new file I have created I have called midfile and the line of text which will be added is called myline.
At the moment the new file is created but it only contains the line which is supposed to go in the middle. Im guessing the mistake I have made is simple but can't seem to figure out where I have gone wrong. Many Thanks in Advance.
"<" is the indirection, which is sending file o/p to the command line by line.
as a result of that, you will get the line count only. ( unlikely the filename also which you get in the another command.)
if you use first command than you will have to suppress the filename part.