[bash] transfer last line to first place
I want to transfer last line in the file to the first place, without processing all file. Is it possible?
For example if I have Code:
Line 1... Code:
Line n... Code:
Line n... |
Maybe using something like
Code:
cat <(tail -n1 file) <(head -n-1 file) |
Quote:
|
OK, solved)
Code:
size=`wc -l file.in | awk '{print $1}'` |
Nice! Actually the size calculation is not necessary since option -n of the head command accepts negative numbers to print all but the last N lines of each file. Specifying
Code:
head -n-1 |
Great! thanks. but I found easier method again) without creating new files
Code:
total=`tail -n 1 "file"` |
Hi.
Here is even simpler solution: Code:
$ cat infile2.txt |
All times are GMT -5. The time now is 11:55 AM. |