Create a new file by removing the new line character at the end of file
I have a flat file which contains the following data records between H: and T:.
H:20050427 HEADER RECORD
0000000 00000 000000000 123456 00 654321 DATARECORD
0000000 00000 000000000 123456 00 654321 DATARECORD
0000000 00000 000000000 123456 00 654321 DATARECORD
0000000 00000 000000000 123456 00 654321 DATARECORD
T:20050427 TRAILER RECORD
[blank space]
[blank space] is a new line (carriage return key) created with no records after T:
How do I remove the blank space(s) (if present) from the f开发者_开发知识库ile and create a new file with data which are present between H: and T:?
Thanks, Arun
If you want to remove all blank lines from your file, why don't you grep for lines that have non-whitespace?
$ grep -e \\S <myfile> > <newfile>
\S
is shorthand for "non-whitespace" The \
has to be escaped so that the shell passes it through, which is why you need two backslashes.
精彩评论