z**w 发帖数: 69 | 1 I have a txt file containing a matrix that I need. But there
are 15 lines of unwanted text at the begining, also some unwanted
text to the right of the matrix.
for example the file may look like this:
(Begining of file)
junk junk junk ............
.... (15 line of junk)
junk junk junk ............
0 0 1 2 3 4 5
2 3 5 2 2 3 4 junk
......
......
......
3 3 4 2 4 2 3
(End of file)
How do I get rid of texts of the begining 15 lines
and the texts on the right, leaving only the matrix in a | D**e 发帖数: 10169 | 2 if you know the dimension of the matrix, it's easy. suppose it's MxN. and M/N
is not too large.
tail -n M infile | awk '{printf "%d %d ... %d\n", $1, $2, ..., $n}' > outfile
【在 z**w 的大作中提到】 : I have a txt file containing a matrix that I need. But there : are 15 lines of unwanted text at the begining, also some unwanted : text to the right of the matrix. : for example the file may look like this: : (Begining of file) : junk junk junk ............ : .... (15 line of junk) : junk junk junk ............ : 0 0 1 2 3 4 5 : 2 3 5 2 2 3 4 junk
| z**w 发帖数: 69 | 3 the number of columns of the matrix is not constant.
how can I retrieve this number from "wc -l"?
or is there any options of "tail" to take the all the contents starting
from line 16?
thanks..
M/N
outfile
【在 D**e 的大作中提到】 : if you know the dimension of the matrix, it's easy. suppose it's MxN. and M/N : is not too large. : tail -n M infile | awk '{printf "%d %d ... %d\n", $1, $2, ..., $n}' > outfile
|
|