Sponsored Content
Top Forums Shell Programming and Scripting Splitting a single line into multiple lines Post 63132 by thanuman on Tuesday 22nd of February 2005 10:59:50 PM
Old 02-22-2005
Splitting a single line into multiple lines

I have a case where, I need to look into a file.
Go to each line of the file, find the length of the line, if the length of the line is more than 75 chars, I need to split the line into multiple lines of 75chars max. If the length of the line is less than 75, we need not do anything.
So at the end of this operation , maximum length of anyline in the file should be only 75.

Ex: file having 3 lines
1st line: 20chars
2nd line: 85chars
3rd line: 160chars

after the executing the script,
The file should be

1st line:20 chars

2nd line: 75 chars
3rd line: 10 chars

4th line: 75 chars
5th line: 75 chars
6th line: 10 chars

Thanks for your help
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Splitting the line in multiple lines

Hi Guys, I need a help. I am pretty new to the shell level programing. I was trying to split a long lines to a multiple lines with few conditions. I goggle for the code and found some snippets and tried to modified it but I got few strange problems too. I have to split the lines if line is ... (3 Replies)
Discussion started by: dd_sh
3 Replies

2. Shell Programming and Scripting

Multiple lines into a single line

Hi, I've some files with the following data and i need to convert the lines between the separator ---, into a single line. I've tried with the paste cmd but my main problem is that the number of lines between the separator is not fix, it can very between 1-4 lines. Input --- 2010-02-22... (4 Replies)
Discussion started by: RickyC9999
4 Replies

3. Shell Programming and Scripting

Combine multiple lines in single line

This is related to one of my previous post but now with a slight difference: I need the "Updated:" to be in one line as well as the "Information:" on one line as well. These are in multiple lines right now as seen below. These can have 2 or more lines that needs to be in one line. System name:... (8 Replies)
Discussion started by: The One
8 Replies

4. Shell Programming and Scripting

Multiple lines in a single column to be merged as a single line for a record

Hi, I have a requirement with, No~Dt~Notes 1~2011/08/1~"aaa bbb ccc ddd eee fff ggg hhh" Single column alone got splitted into multiple lines. I require the output as No~Dt~Notes 1~2011/08/1~"aaa<>bbb<>ccc<>ddd<>eee<>fff<>ggg<>hhh" mean to say those new lines to be... (1 Reply)
Discussion started by: Bhuvaneswari
1 Replies

5. Shell Programming and Scripting

splitting a huge line of file into multiple lines with fixed number of columns

Hi, I have a huge file with a single line. But I want to break that line into lines of with each line having five columns. My file is like this: code: "hi","there","how","are","you?","It","was","great","working","with","you.","hope","to","work","you." I want it like this: code:... (1 Reply)
Discussion started by: rajsharma
1 Replies

6. Shell Programming and Scripting

Splitting Single line into multiple line

Hi All, I am reading a line from a file and writing it to other file. Whenever I got a particular line then I want that line to be splited into 4 line and written it to new file. e.g My line is U_ABC connector3 pin24E connector4 pin25E connector5 pin26E connector6 pin27E connector7... (2 Replies)
Discussion started by: diehard
2 Replies

7. Shell Programming and Scripting

Splitting one line into multiple lines

Hi, I have one problem scenorio as below. my source file is : cat input_file. "hi","there","how","are","you?","It","was","great","working","with","you.","hope","to","work","y ou." my output should be like. "hi","there","how","are","you?", "It","was","great","working","with",... (7 Replies)
Discussion started by: abhilash_nakka
7 Replies

8. Shell Programming and Scripting

Making multiple lines as single line

Hi All, I have a spool file which as shown below. I want to make it as single line after every semicolon. In this case there should be 2 lines in vi editor. I am not used to use sed so could you guys please help me out ? exec spk_dba.sp_runsql('ALP','CREATE DATABASE LINK "TEST" CONNECT TO... (2 Replies)
Discussion started by: nicolas38
2 Replies

9. Shell Programming and Scripting

Merge multiple lines into a single line

Hi all, I'm relatively new to scripting, I can do pretty basic things. I have a daily log file that looks like: timestamp=2017-06-28-01.01.35.080576; event status=0; userid=user1; authid=user1; application id=10.10.10.10.11111.12345678901; application name=GUI; ... (29 Replies)
Discussion started by: dwdnet
29 Replies

10. UNIX for Beginners Questions & Answers

Multiple lines to single line

I have code as below # create temporary table `temp4277`(key(waybill_no)) select waybill_no,concat_ws('',card_type,card_series_no) cardinfo from rfid_temp_ticket where waybill_no='4277' group by... (4 Replies)
Discussion started by: kaushik02018
4 Replies
UNROFF(1)						      General Commands Manual							 UNROFF(1)

NAME
unroff - convert troff documents to plain text SYNTAX
unroff [ -E ] [ -J ] [ -8 ] [ -mxx ] [ file ... ] DESCRIPTION
unroff processes documents written to be formatted with troff (or nroff, or any of the other *roff variants) and converts them to plain text. This is similar to what deroff does, but the result is sometimes better than deroff output. Optional flags may be given to modify the operation of unroff, as follows: -E Echo input tokens as they are read. Useful mainly for debugging. -J Join output lines that would be part of a single paragraph so they form a single output line. This is useful if you plan to move the resulting output into a document formatter that treats paragraphs as a single line. The default is to do line wrapping accord- ing to the line length specified in the input document. -8 Write 8-bit ISO Latin-1 (ISO 8859-1) characters. This option may be useful for producing output intended to be viewed on devices capable of 8-bit character display. Without this option, 8-bit Latin-1 characters will generall appear in the output as ``[[name]]'' where ``name'' is the troffcvt internal name for the character, e.g., ``[[Aacute]]''. For some of these characters, an ASCII approximation will be used if something reasonably close is available. -mxx Specify macro package, usually -man, -me, -mm, or -ms. DIAGNOSTICS
line length clipped to nnn chars. A very long line length was requested, so long that it would likely result in output line assembly buf- fer overflow. The length is clipped to prevent this. output buffer capacity exceeded. This means some line is so long that it couldn't be collected in the output line assembly buffer. Most likely this signals a bug in tc2text, since the length is supposed to be kept within reasonable bounds (see previous paragraph). SEE ALSO
troffcvt(1), tc2text(1) WHO-TO-BLAME Paul DuBois, dubois@primate.wisc.edu. BUGS
unroff doesn't do so well with tables, particularly tables with multiple-line cells. Table centering isn't handled. UNROFF(1)
All times are GMT -4. The time now is 06:42 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy