File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Linux / UNIX and the fly likes shell script to get the end of line Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Engineering » Linux / UNIX
Bookmark "shell script to get the end of line " Watch "shell script to get the end of line " New topic
Author

shell script to get the end of line

yuga devi
Greenhorn

Joined: Aug 07, 2008
Posts: 22
Hi,

Can anybody tell me to get the end of line in a file using shell script?

--Yug

Balu Sadhasivam
Ranch Hand

Joined: Jan 01, 2009
Posts: 874


use 'cat filename | tail -1'
yuga devi
Greenhorn

Joined: Aug 07, 2008
Posts: 22
Hi,

I hope,
use 'cat filename | tail -1' - this command returns the end of file.

I want to get the end of each line in a file to parse some data.
Balu Sadhasivam
Ranch Hand

Joined: Jan 01, 2009
Posts: 874



I want to get the end of each line in a file to parse some data.


what do you mean by that . if i understood tat , end of each line will ultimately return you the entire file
Ananth Chellathurai
Ranch Hand

Joined: Nov 21, 2007
Posts: 349

Did you mean getting the last line of a file?



Ananth Chellathurai [Walk on software]
yuga devi
Greenhorn

Joined: Aug 07, 2008
Posts: 22
Thankyou for the reply.
Let me explain my scenario:

For example, i have the following lines in a file:

"The split command reads input from a file or the standard input and creates multiple output files. Thus it is suitable as the last stage of the pipeline.
Each file contains n lines of the original. If you do not provide n,
split uses the value of 1000. You can split file into chanks on one line per file using n=1. "



I want to split this files, into multiple files based on some byte size - say 5k

split -b 5k <source file>

While splitting, say for ex, if the first 5k size ends like in the mid of any line

"The split command reads input from a file or the standard input and creates multiple output files. Thus it is suitable as the last stage of the pipeline.
Each file contains ",


i would like to get till the end of this line

I mean till " Each file contains n lines of the original. If you do not provide n,"

Is this possible??
Hope i am clear
-- Yuga

Ananth Chellathurai
Ranch Hand

Joined: Nov 21, 2007
Posts: 349

It should be possible. Read the file line by line and write it to another file. Check the new file size after writing eachline, when it reaches some limit start writing the remaining to a new file.

For reading line by line.
For finding file size.
yuga devi
Greenhorn

Joined: Aug 07, 2008
Posts: 22
Hi,

Thankyou..

But one setback here is : My source file is bigger -around 50000 lines. So, in such a big file, there is a possibility of performance issue.

So is there any other solution, to do this .Without writing it into another file.

Thanks in advance,
--yuga
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: shell script to get the end of line
 
Similar Threads
Maximum length of Command Line Argument
line breaks in dos commands
URGENT !! How can a shell script get the System.exit() exit value?
how to invoke a java program using shellscript
porting a .bat file to unix