Sponsored Content
Top Forums Shell Programming and Scripting Sed - merge lines bw 2 specific characters Post 302509097 by kurumi on Tuesday 29th of March 2011 08:37:46 PM
Old 03-29-2011
Code:
$ ruby -ne 'print (/]$/) ? $_ : $_.chomp  if $.>4' file
tagId=6, length=8, value=[ 30 30 2d 30 36 ]
tagId=9, length=5, value=[ 35 30 31 ]
tagId=7, length=2, value=[ 00 8c ]
tagId=16, length=2, value=[ 00 00 ]
tagId=32, length=1, value=[ 19 ]
tagId=33, length=1, value=[ 62 ]
tagId=34, length=1, value=[ 15 ]
tagId=35, length=16, value=[ 00 01 00 03 55 ea 00 00 00 00 00 00 00 00 00 00]
tagId=35, length=16, value=[ 00 04 00 00 4a 93 00 15 00 00 00 00 29 45 55 00]
tagId=35, length=16, value=[ 00 01 00 03 6b 22 00 00 00 00 00 00 00 00 00 00]
tagId=35, length=16, value=[ 00 01 00 02 35 d4 00 00 00 00 00 00 00 00 00 00]
tagId=35, length=16, value=[ 00 04 00 0b 80 84 00 3d 00 00 00 00 47 dd b4 80]
tagId=35, length=16, value=[ 00 04 00 0b 80 84 00 24 00 00 00 00 45 7c 9f 80]
tagId=35, length=16, value=[ 00 04 00 0b 80 84 00 25 00 00 00 00 45 6a 2a 80]
tagId=35, length=16, value=[ ]
tagId=35, length=16, value=[ ]
tagId=35, length=16, value=[ ]
tagId=48, length=4, value=[ 00 00 00 0b ]
tagId=64, length=4, value=[ 00 00 00 21 ]
tagId=65, length=1, value=[ 00 ]
tagId=80, length=2, value=[ 00 00 ]
tagId=81, length=2, value=[ 00 00 ]
tagId=144, length=2, value=[ 00 02 ]
tagId=4, length=1, value=[ 02 ]
tagId=128, length=32, value=[ 34 67 23 65 21 87 45 98 34 31 30 33 31 3031 34 35 31 5f 90 30 38 30 35 38 30 34]


Last edited by kurumi; 03-30-2011 at 12:44 AM..
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Use sed to merge multiple lines

Hi all: I have a file in which the contents are as following: ... This is a test ONE TWO Hello, world! XXX YYY CCC test again three, four five six seven world AAA BBB QQQ test eight, nine world (3 Replies)
Discussion started by: xb88
3 Replies

2. Shell Programming and Scripting

Merge lines in Flat file based on first 5 characters

Hi I have the fixed width flat file having the following data 12345aaaaaaaaaabbbbbbbbbb 12365sssssssssscccccccccc 12365sssss 12367ddddddddddvvvvvvvvvv 12367 vvvvv Here the first column is length 5 second is length 10 third is length 10 if the second or third column exceeds... (3 Replies)
Discussion started by: Brado
3 Replies

3. UNIX Desktop Questions & Answers

grep lines with two specific characters somewhere in the line

I'm having trouble with extracting certain lines from a file based on whether they have all the required fields. Original file: snt:594:Sam N This bpt:2342:Bob P That lr:123 wrp:23:Whoever Person cor:794 Desired output: snt:594:Sam N This bpt:2342:Bob P That wrp:23:Whoever Person ... (3 Replies)
Discussion started by: Chthonic
3 Replies

4. Shell Programming and Scripting

Merge two lines using sed

Hi, I am trying to merge two lines, first line starts with a particular pattern and second line ends with a particular pattern in a file. Something like: First line starts with say ABC Second line ends with say XYZ After a merge, the line should become ABC.......XYZ I tried... (14 Replies)
Discussion started by: Sunny Arora
14 Replies

5. Shell Programming and Scripting

sed replacing specific characters and control characters by escaping

sed -e "s// /g" old.txt > new.txt While I do know some control characters need to be escaped, can normal characters also be escaped and still work the same way? Basically I do not know all control characters that have a special meaning, for example, ?, ., % have a meaning and have to be escaped... (11 Replies)
Discussion started by: ijustneeda
11 Replies

6. Shell Programming and Scripting

Summing over specific lines and replacing the lines with the sum using sed, awk

Hi friends, This is sed & awk type question. I have a text file which has numbers spread all over the file. I want to sum the series of numbers whenever i find it and produce an output file with the sum. For example ###start of input text file #### abc def ghi 1 2 3 4 kjld random... (3 Replies)
Discussion started by: kaaliakahn
3 Replies

7. Shell Programming and Scripting

How delete characters of specific line with sed?

Hi, I have a text file with some lines like this: /MEDIA/DISK1/23568742.MOV /MEDIA/DISK1/87456321.AVI /MEDIA/DISK2/PART1/45753131.AVI /IMPORT/44452.WAV ... I want to remove the last 12 characters in each line that it ends "AVI". Should look like this: /MEDIA/DISK1/23568742.MOV... (12 Replies)
Discussion started by: inaki
12 Replies

8. Shell Programming and Scripting

Replacing specific characters using sed

Hi, I have a text file which is output from a server and it lists all the files in a specific volume. However, the volume name appears as volume_name:. I would like to replace this with \\volume_name\volume_name. This is not a problem in itself as I can use sed to globally look for the... (8 Replies)
Discussion started by: vnayak
8 Replies

9. Shell Programming and Scripting

ksh sed - Extract specific lines with mulitple occurance of interesting lines

Data file example I look for primary and * to isolate the interesting slot number. slot=`sed '/^primary$/,/\*/!d' filename | tail -1 | sed s'/*//' | awk '{print $1" "$2}'` Now I want to get the Touch line for only the associate slot number, in this case, because the asterisk... (2 Replies)
Discussion started by: popeye
2 Replies

10. Shell Programming and Scripting

Merge lines with varying characters

Hi, I have a large set of data (firewall logs) that I'm trying to summarize. I've been able to write a script to consolidate the ports, now am looking to conslidate even further, based on IP. Source Destination Type Port 192.168.5.108 192.168.11.12 TCP 1, 2, 3, 4, 5, 15 192.168.5.109... (6 Replies)
Discussion started by: umang2382
6 Replies
ICONV_SUBSTR(3) 							 1							   ICONV_SUBSTR(3)

iconv_substr - Cut out part of a string

SYNOPSIS
string iconv_substr (string $str, int $offset, [int $length = iconv_strlen($str, $charset)], [string $charset = ini_get("iconv.inter- nal_encoding")]) DESCRIPTION
Cuts a portion of $str specified by the $offset and $length parameters. PARAMETERS
o $str - The original string. o $offset - If $offset is non-negative, iconv_substr(3) cuts the portion out of $str beginning at $offset'th character, counting from zero. If $offset is negative, iconv_substr(3) cuts out the portion beginning at the position, $offset characters away from the end of $str. o $length - If $length is given and is positive, the return value will contain at most $length characters of the portion that begins at $offset (depending on the length of $string). If negative $length is passed, iconv_substr(3) cuts the portion out of $str from the $offset'th character up to the character that is $length characters away from the end of the string. In case $offset is also negative, the start position is calculated beforehand according to the rule explained above. o $charset - If $charset parameter is omitted, $string are assumed to be encoded in iconv.internal_encoding. Note that $offset and $length parameters are always deemed to represent offsets that are calculated on the basis of the character set determined by $charset, whilst the counterpart substr(3) always takes these for byte offsets. RETURN VALUES
Returns the portion of $str specified by the $offset and $length parameters. If $str is shorter than $offset characters long, FALSE will be returned. SEE ALSO
substr(3), mb_substr(3), mb_strcut(3). PHP Documentation Group ICONV_SUBSTR(3)
All times are GMT -4. The time now is 06:15 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy