New line


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting New line
# 1  
Old 05-22-2012
New line

I have a file which is in a hex format and i wanted to have a new line for every "DF" found in it. Please see below format

DF 00 01 23 01 00 00 00 DC 6B 00 00 00 00 7B 36 19 07 00 00 31 FF FF FF FF 00 00 00 05 05 32 04 22 20 69 F1 FF FF FF FF FF FF FF FF 16 34 74 53 02 F1 FF FF FF FF 00 03 FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF 06 09 76 82 74 52 FF FF FF FF FF FF FF FF FF 00 36 09 76 82 74 52 FF FF FF FF FF 14 05 27 4B 36 19 07 00 00 31 FF FF FF FF 40 06 34 A1 FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF 25 14 08 00 00 11 00 FF FF 38 25 55 14 23 04 12 20 29 55 14 23 04 12 20 35 55 14 23 04 12 20 16 56 14 23 04 12 20 42 00 00 00 00 00 00 00 00 03 11 00 00 00 00 00 00 05 FF FF FF 00 06 09 76 82 74 52 FF FF FF FF FF FF FF FF FF FF FF 05 FF FF FF FF FF 00 FF FF 00 02 DF 00 01 24 01 00 00 00 12 6A 00 00 00 00 7C 36 19 07 00 00 31 FF FF FF FF 00 00 00 05 05 32 04 22 20 69 F1 FF FF FF FF FF FF FF FF 16 34 74 53 02 F1 FF FF FF FF 00 03 FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF 06 09 76 82 74 52 FF FF FF FF FF FF FF FF FF 00 36 09 76 82 74 52 FF FF FF FF FF 14 05 27 4B 36 19 07 00 00 31 FF FF FF FF 40 06 34 A1 FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF 25 14 11 00 00 11 00 FF FF 38 03 00 15 23 04 12 20 09 00 15 23 04 12 20 10 00 15 23 04 12 20 26 00 15 23 04 12 20 16 00 00 00 00 00 00 00 00 03 11 00 00 00 00 00 00 05 FF FF FF 00 06 09 76 82 74 52 FF FF FF FF FF FF FF FF FF FF FF 05 FF FF FF FF FF 00 FF FF 00 02 18 00 10 36 19 07 00 00 31 FF FF FF FF 03 00 15 23 04 12 20 24 01 00 00 FF FF FF FF FF FF FF FF FF

Need all your help.

Thanks,
r31gn
# 2  
Old 05-23-2012
How would you want the output to look like?
# 3  
Old 05-23-2012
i wanted it that every DF found would create a new line. say

DF 00 01 23 01 00 00 00 DC 6B 00 00 00 00 7B 36 19 07 00 00 31 FF FF FF FF 00 00 00 05 05 32 04 22 20 69 F1 FF FF FF FF FF FF FF FF 16 34 74 53 02 F1 FF FF FF FF 00 03 FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF 06 09 76 82 74 52 FF FF FF FF FF FF FF FF FF 00 36 09 76 82 74 52 FF FF FF FF FF 14 05 27 4B 36 19 07 00 00 31 FF FF FF FF 40 06 34 A1 FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF 25 14 08 00 00 11 00 FF FF 38 25 55 14 23 04 12 20 29 55 14 23 04 12 20 35 55 14 23 04 12 20 16 56 14 23 04 12 20 42 00 00 00 00 00 00 00 00 03 11 00 00 00 00 00 00 05 FF FF FF 00 06 09 76 82 74 52 FF FF FF FF FF FF FF FF FF FF FF 05 FF FF FF FF FF 00 FF FF 00 02
DF 00 01 24 01 00 00 00 12 6A 00 00 00 00 7C 36 19 07 00 00 31 FF FF FF FF 00 00 00 05 05 32 04 22 20 69 F1 FF FF FF FF FF FF FF FF 16 34 74 53 02 F1 FF FF FF FF 00 03 FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF 06 09 76 82 74 52 FF FF FF FF FF FF FF FF FF 00 36 09 76 82 74 52 FF FF FF FF FF 14 05 27 4B 36 19 07 00 00 31 FF FF FF FF 40 06 34 A1 FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF 25 14 11 00 00 11 00 FF FF 38 03 00 15 23 04 12 20 09 00 15 23 04 12 20 10 00 15 23 04 12 20 26 00 15 23 04 12 20 16 00 00 00 00 00 00 00 00 03 11 00 00 00 00 00 00 05 FF FF FF 00 06 09 76 82 74 52 FF FF FF FF FF FF FF FF FF FF FF 05 FF FF FF FF FF 00 FF FF 00 02 18 00 10 36 19 07 00 00 31 FF FF FF FF 03 00 15 23 04 12 20 24 01 00 00 FF FF FF FF FF FF FF FF FF

thanks
# 4  
Old 05-23-2012
Code:
sed "s/DF/\nDF/g" file

# 5  
Old 05-23-2012
never thought sed can do this. Thanks man
# 6  
Old 05-23-2012
Most seds know '\n' in the replacement part, but is is not universal (POSIX). This should work in every sed:
Code:
sed "s/DF/\
DF/g" file

Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Get an output of lines in pattern 1st line then 10th line then 11th line then 20th line and so on.

Input file: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 (6 Replies)
Discussion started by: Sagar Singh
6 Replies

2. Shell Programming and Scripting

How to read file line by line and compare subset of 1st line with 2nd?

Hi all, I have a log file say Test.log that gets updated continuously and it has data in pipe separated format. A sample log file would look like: <date1>|<data1>|<url1>|<result1> <date2>|<data2>|<url2>|<result2> <date3>|<data3>|<url3>|<result3> <date4>|<data4>|<url4>|<result4> What I... (3 Replies)
Discussion started by: pat_pramod
3 Replies

3. 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

4. Shell Programming and Scripting

sed command to replace a line at a specific line number with some other line

my requirement is, consider a file output cat output blah sdjfhjkd jsdfhjksdh sdfs 23423 sdfsdf sdf"sdfsdf"sdfsdf"""""dsf hellow there this doesnt look good et cetc etc etcetera i want to replace a line of line number 4 ("this doesnt look good") with some other line ... (3 Replies)
Discussion started by: vivek d r
3 Replies

5. Shell Programming and Scripting

how to read the contents of two files line by line and compare the line by line?

Hi All, I'm trying to figure out which are the trusted-ips and which are not using a script file.. I have a file named 'ip-list.txt' which contains some ip addresses and another file named 'trusted-ip-list.txt' which also contains some ip addresses. I want to read a line from... (4 Replies)
Discussion started by: mjavalkar
4 Replies

6. Solaris

Line too long error Replace string with new line line character

I get a file which has all its content in a single row. The file contains xml data containing 3000 records, but all in a single row, making it difficult for Unix to Process the file. I decided to insert a new line character at all occurrences of a particular string in this file (say replacing... (4 Replies)
Discussion started by: ducati
4 Replies

7. Shell Programming and Scripting

Fill the empty line by adding line before blank line

FIle A "A" 2 aa 34 3 ac 5 cd "B" 3 hu 67 4 fg 5 gy output shud be A"" 2 aa 34 "A" 3 ac 34 "A" 5 cd 34 "B" 3 hu 67 "B" 4 fg 67 "B" 5 gy 67 (6 Replies)
Discussion started by: cdfd123
6 Replies

8. Shell Programming and Scripting

[Solved] Problem in reading a file line by line till it reaches a white line

So, I want to read line-by-line a text file with unknown number of files.... So: a=1 b=1 while ; do b=`sed -n '$ap' test` a=`expr $a + 1` $here do something with b etc done the problem is that sed does not seem to recognise the $a, even when trying sed -n ' $a p' So, I cannot read... (3 Replies)
Discussion started by: hakermania
3 Replies

9. UNIX for Advanced & Expert Users

how do you parse 1 line at a time of file1 ie. line(n) each line into new file

File 1 <html>ta da....unique file name I want to give file=>343...</html> <html>da ta 234 </html> <html>pa da 542 </html> and so on... File 2 343 234 542 and so on, each line in File 1 one also corresponds with each line in File 2 I have tried several grep, sed, while .. read, do,... (4 Replies)
Discussion started by: web_developer
4 Replies
Login or Register to Ask a Question