Sponsored Content
Top Forums Shell Programming and Scripting read one line file and separate into multiple lines Post 302578899 by erlanq on Friday 2nd of December 2011 08:36:53 PM
Old 12-02-2011
read one line file and separate into multiple lines

I have one long line text with semicolon used as separator between values in that line. Now, I want to separate the line into multiple line right after every 29th field.

example input line:
Code:
192.168.1.145;44535;software20.org;80;yes;ThuDec113;50;50.8384422011;ThuDec113;50;57.2764792011;0;00;06.438037;58;29;29;28;29;1;25;526;36045;0;0;0;0;1/1;1/1;0;0;0;0;82;5599;346.4;1.6;192.168.1.145;44536;software20.org;80;yes;ThuDec113;50;51.5587192011;ThuDec113;51;10.7557082011;0;00;19.196988;224;97;127;96;127;7;124;3963;173749;3;0;3;0;1/4;1/1;0;0;0;0;206;9051;351.8;2.4;192.168.1.145;44537;software20.org;80;yes;ThuDec113;50;51.8373732011;ThuDec113;51;11.4517212011;0;00;19.614348;455;185;270;184;270;5;267;2772;383480;3;0;3;0;1/4;1/1;0;0;0;0;141;19551;346.2;2.9;

output:
Code:
192.168.1.145;44535;software20.org;80;yes;ThuDec113;50;50.8384422011;ThuDec113;50;57.2764792011;0;00;06.438037;58;29;29;28;29;1;25;526;36045;0;0;0;0;1/1;1/1;0;0;0;0;82;5599;346.4;1.6;
192.168.1.145;44536;software20.org;80;yes;ThuDec113;50;51.5587192011;ThuDec113;51;10.7557082011;0;00;19.196988;224;97;127;96;127;7;124;3963;173749;3;0;3;0;1/4;1/1;0;0;0;0;206;9051;351.8;2.4;
192.168.1.145;44537;software20.org;80;yes;ThuDec113;50;51.8373732011;ThuDec113;51;11.4517212011;0;00;19.614348;455;185;270;184;270;5;267;2772;383480;3;0;3;0;1/4;1/1;0;0;0;0;141;19551;346.2;2.9;

thanks for your pointer...
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

bash: read file line by line (lines have '\0') - not full line has read???

I am using the while-loop to read a file. The file has lines with null-terminated strings (words, actually.) What I have by that reading - just a first word up to '\0'! I need to have whole string up to 'new line' - (LF, 10#10, 16#A) What I am doing wrong? #make file 'grb' with... (6 Replies)
Discussion started by: alex_5161
6 Replies

2. Shell Programming and Scripting

Read 1-line file and separate into multiple variables

I have one line files with 17 records separated by a semi-colon. I need to create a variable from each record, which I can do via a separate awk for each one, but I know there has to be a better way. Along with pulling out the variable, I need to convert some url coding like a + to a space, etc.... (4 Replies)
Discussion started by: numele
4 Replies

3. Shell Programming and Scripting

extract nth line of all files and print in output file on separate lines.

Hello UNIX experts, I have 124 text files in a directory. I want to extract the 45678th line of all the files sequentialy by file names. The extracted lines should be printed in the output file on seperate lines. e.g. The input Files are one.txt, two.txt, three.txt, four.txt The cat of four... (1 Reply)
Discussion started by: yogeshkumkar
1 Replies

4. Shell Programming and Scripting

Read file contents and separate the lines when completes with =

Hi, I have a file like this cpsSystemNotifyTrap='2010/12/14 11:05:31 CST' Manufacturer=IBM ReportingMTMS=n/a ProbNm=26 LparName=n/a FailingEnclosureMTMS=7946-IQL*99G4874 SRC=B3031107 EventText=Problem reported by customer. CallHome=true Calendar I want to have a output like this... (6 Replies)
Discussion started by: dbashyam
6 Replies

5. Shell Programming and Scripting

How to separate file to multiple line.

Hi Unix gurus, I am facing a problme with file. I need separate my file into multiple line. eg. Soure file: PRT07, aaa, bbb, 46, PRT06, ccc, ddd, 57, PRT05, eee,fff,aa, target file: PRT07, aaa, bbb, 46 PRT06, ccc, ddd, 57 PRT05, eee,fff,aa :wall: thanks in advance (4 Replies)
Discussion started by: ken002
4 Replies

6. Shell Programming and Scripting

read one line file and separate into multiple lines

I have one long line text with semicolon used as separator between values in that line. Now, I want to separate the line into multiple line right after every 29th field. example input line: ... (1 Reply)
Discussion started by: erlanq
1 Replies

7. Shell Programming and Scripting

Shell script to read multiple options from file, line by line

Hi all I have spent half a day trying to create a shell script which reads a configuration file on a line by line basis. The idea of the file is that each will contain server information, such as IP address and various port numbers. The line could also be blank (The file is user created). Here... (1 Reply)
Discussion started by: haggismn
1 Replies

8. Shell Programming and Scripting

Read each line and saving the line in separate files

Hi Experts, I am having a requirement like this; Input file EIM_ACCT.ifb|1001|1005 EIM_ADDR.ifb|1002|1004 EIM_ABD.ifb|1009|1007 I want to read each line of this file and pass each line,one at a time,as an argument to another script. eg; 1.read first line->store it to a file->call... (2 Replies)
Discussion started by: ashishpanchal85
2 Replies

9. Programming

Read text from file and print each character in separate line

performing this code to read from file and print each character in separate line works well with ASCII encoded text void preprocess_file (FILE *fp) { int cc; for (;;) { cc = getc (fp); if (cc == EOF) break; printf ("%c\n", cc); } } int main(int... (1 Reply)
Discussion started by: khaled79
1 Replies

10. Shell Programming and Scripting

Need a program that read a file line by line and prints out lines 1, 2 & 3 after an empty line...

Hello, I need a program that read a file line by line and prints out lines 1, 2 & 3 after an empty line... An example of entries in the file would be: SRVXPAPI001 ERRO JUN24 07:28:34 1775 REASON= 0000, PROCID= #E506 #1065: TPCIPPR, INDEX= 003F ... (8 Replies)
Discussion started by: Ferocci
8 Replies
pydhcplib.ipv4(3)						     PYDHCPLIB							 pydhcplib.ipv4(3)

NAME
pydhcplib.ipv4 - Type for IP addresses version 4 SYNOPSIS
from pydhcplib.type_ipv4 import ipv4 a = ipv4() a = ipv4(string) a = ipv4(strlist) a = ipv4(int) DESCRIPTION
The class pydhcplib.ipv4 is a type "IP address version 4". It's used for string processing like "192.168.0.4". The class creation argument can be a string like "192.168.0.4". The class creation argument can be a list of bytes like [192,168,0,4]. METHODS
The implemented methods in this class are mostly methods of comparison (= =, >, etc...) else : str() return data converted into a printable string. list() return data converted into a list of bytes. int() return data converted into an 4 bytes int. EXAMPLES
Example program ipv4_example.py : from pydhcplib.type_ipv4 import ipv4 address = ipv4() address1 = ipv4("192.168.0.1") address2 = ipv4("10.0.0.1") address3 = ipv4([192,168,0,1]) print "a0 : ",address print "a1 : ",address1 print "a2 : ",address2 print "a3 : ",address3 if address1 == address2 : print "test 1 : ",address1, "==",address2 else : print "test 1 : " ,address1, "!=",address2 if address1 == address3 : print "test 2 : ", address1, "==",address3 else : print "test 2 : ", address1, "!=",address3 SEE ALSO
pydhcp(8), pydhcplib.hwmac(3), pydhcplib.ipv4(3), pydhcplib.strlist(3), pydhcplib.DhcpPacket(3), pydhcplib.DhcpBasicPacket(3), pydhc- plib.DhcpNetwork(3), pydhcplib.DhcpClient(3), pydhcplib.DhcpRawClient(3), pydhcplib.DhcpDerver(3) BUGS
See http://pydhcplib.tuxfamily.org/ for more information. AUTHOR
Mathieu Ignacio (mignacio[AT]april.org) pydhcplib.ipv4(3)
All times are GMT -4. The time now is 06:28 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy