• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

shell script to get the end of line

 
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

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

--Yug

 
Ranch Hand
Posts: 874
Android VI Editor Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

use 'cat filename | tail -1'
 
yuga devi
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 874
Android VI Editor Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator


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
 
Ranch Hand
Posts: 349
Hibernate Eclipse IDE Spring
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Did you mean getting the last line of a file?

 
yuga devi
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 349
Hibernate Eclipse IDE Spring
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 22
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic