Hi
I need assistance with a loop routine that counts the number of lines in a file then extracts the last line into a new file. The problem I am running into is the number of lines in file A will be dynamic.
I need a way to subtract the lines in File A one at a time and output them into File B. File B can never have more than one line since I am using the line as a variable for another function. I would prefer to just delete each line from file A and output them to file B but cut is not able to do this and I haven't had much luck with sed.
for i in $fileA
do
x=`cat $i | wc -l`
y=`expr $x - 1`
z=`expr $x - $y`
nawk 'NR == 1, NR == '"$z"' {print}' $i > $FileB
I need assistance with a loop routine that counts the number of lines in a file then extracts the last line into a new file. The problem I am running into is the number of lines in file A will be dynamic.
I need a way to subtract the lines in File A one at a time and output them into File B. File B can never have more than one line since I am using the line as a variable for another function. I would prefer to just delete each line from file A and output them to file B but cut is not able to do this and I haven't had much luck with sed.
for i in $fileA
do
x=`cat $i | wc -l`
y=`expr $x - 1`
z=`expr $x - $y`
nawk 'NR == 1, NR == '"$z"' {print}' $i > $FileB