05-25-2006
Using sed with strings of special characters
Hey, I'm having trouble figuring out the syntax for using sed with string of non-printable characters. What I have is the following format:
<field>@@;@@<field>@@;@@...@@;@@<field>@@^@@<field>@@;@@<field>@@;@@...@@;@@<field>@@^@@
...
With the @@;@@ being the delimeters between fields and the @@^@@ representing new lines. I need to replace the @@;@@ with commas, and the @@^@@ with actual new lines because there are none actually in the file. Can anyone help me out with the syntax to do this with sed or whatever would be the best option? Also, these delimeters could be changed to anything if you have any suggestions of better delimeters. Thanks.
-Richard
Last edited by Dickalicious; 05-25-2006 at 11:14 AM..
10 More Discussions You Might Find Interesting
1. UNIX for Dummies Questions & Answers
please send the logic or program to find the matching characters between two strings
for ex string1 :abc
string2 :adc
no .of matching characters is 2(a,c) (9 Replies)
Discussion started by: akmtcs
9 Replies
2. Shell Programming and Scripting
Hi all,
I want to delete all lowercase characters from my file, but only strings of length 7 and more.
For example, how can I go from:
JHGEFigeIGDUIirfyfiyhgfoiyfKJHGuioyrDHG
To:
JHGEFigeIGDUIKJHGuioyrDHG
There should be a trick to add to sed 's///g', but I can't figure it out.... (2 Replies)
Discussion started by: elbuzzo
2 Replies
3. Shell Programming and Scripting
I have the following line:
4/23/2010 0:00:38.000: Copying $$3MSYDDC02$I would like to use sed (or similiar) to remove everthing between and including $ that appears in the line so it ends up like this.
4/23/2010 0:00:38.000: Copying 3MSYDDC02I have been trying these but i'm really just... (5 Replies)
Discussion started by: jelloir
5 Replies
4. Shell Programming and Scripting
Hello all
I am getting data like
col1 | col2 | col3
asdafa | asdfasfa | asf*&^sgê
345./ |sdfasd23425^%^&^ | sdfsa23
êsfsfd | sf(* | sdfsasf
My requirement is like
I have to to read the file and remove all special characters and hex characters ranging form 00-1f from 1st column, remove %"'... (1 Reply)
Discussion started by: vasuarjula
1 Replies
5. UNIX for Dummies Questions & Answers
After spending sometime playing around with my script I just cannot get it to do what I want. So I decided to ask. My file looks something like this:
I am using the following code to extract sequences that contain dashes
awk '/^>/{id=$0;next}{if (match($1,"-")) print id "\n" $0}' infile
... (17 Replies)
Discussion started by: Xterra
17 Replies
6. Shell Programming and Scripting
I have a list of strings, for example:
set strLst = "file1 file2 file3 file4"
I want to log an error if some of the fields happen to begin with -, or have characters like ; : ' , ? ] { =
Which means for example setting
set ierr = 1 (2 Replies)
Discussion started by: kristinu
2 Replies
7. Shell Programming and Scripting
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
8. Shell Programming and Scripting
Hi All,
Assuming i have got a file test.dat which has contains as follows:
Unix = abc def fgt jug
111 2222 3333
Linux = gggg pppp qqq
C# = ccc ffff llll
I would like to traverse through the file, get the 1st occurance of "=" and then need to get the sting... (22 Replies)
Discussion started by: rtagarra
22 Replies
9. Shell Programming and Scripting
Hi
I have a wired string pattern ( mongo output) which I need to convert to only values.
"_id" : ObjectId("59280d9b95385c78b73252e4"), "categorySetId" : NumberLong(1100000041), "categorySetName" : "PROD GROUP", "serviceableProductFlag" : "N", "categoryId" : NumberLong(1053), "pid" :... (5 Replies)
Discussion started by: Abhayman
5 Replies
10. Shell Programming and Scripting
I have this fastq file:
@M04961:22:000000000-B5VGJ:1:1101:9280:7106 1:N:0:86
GGGGGGGGGGGGCATGAAAACATACAAACCGTCTTTCCAGAAATTGTTCCAAGTATCGGCAACAGCTTTATCAATACCATGAAAAATATCAACCACACCA
+test-1
GGGGGGGGGGGGGGGGGCCGGGGGFF,EDFFGEDFG,@DGGCGGEGGG7DCGGGF68CGFFFGGGG@CGDGFFDFEFEFF:30CGAFFDFEFF8CAF;;8... (10 Replies)
Discussion started by: Xterra
10 Replies
PFM Format Description(5) File Formats Manual PFM Format Description(5)
NAME
PFM - PFM graphic image file format
DESCRIPTION
This document describes the PFM graphic image file format as understood by the Netpbm converters pamtopfm(1)
and pfmtopam(1)
There are multiple similar formats known as PFM in the world, none of them authoritatively documented. The format described here is one
that Bryan Henderson deduced from a program he found somewhere that dealt with a 'PFM' format.
The PFM format is inspired by the Netpbm formats, and you will see lots of similarity. It is not, however, an official Netpbm format. Its
goal is not consistent with those of Netpbm formats.
The format
A PFM image is a stream of bytes. The stream consists of a header followed immediately by a raster. These two components are described
below. There are no delimeters before or after the sections as described.
PFM header
The PFM header is 3 consecutive 'lines' of ASCII text. After each line is a white space character. That character is typically a newline
character, hence the term 'line,' but doesn't have to be.
pamtopfm uses a newline in the PFM it generates.
Identifier Line
The identifier line contains the characters 'PF' or 'Pf'. PF means it's a color PFM. Pf means it's a grayscale PFM.
Dimensions Line
The dimensions line contains two positive decimal integers, separated by a blank. The first is the width of the image; the second is the
height. Both are in pixels.
Scale Factor / Endianness
The Scale Factor / Endianness line is a queer line that jams endianness information into an otherwise sane description of a scale. The
line consists of a nonzero decimal number, not necessarily an integer. If the number is negative, that means the PFM raster is little
endian. Otherwise, it is big endian. The absolute value of the number is the scale factor for the image.
The scale factor tells the units of the samples in the raster. You use somehow it along with some separately understood unit information
to turn a sample value into something meaningful, such as watts per square meter.
PFM raster
The raster is a sequence of pixels, packed one after another, with no delimiters of any kind. They are in standard Western reading order:
left to right and top to bottom within the image.
Each pixel consists of 1 or 3 samples, packed one after another, with no delimiters of any kind. 1 sample for a grayscale PFM and 3 for a
color PFM (see the Identifier Line of the PFM header).
Each sample consists of 4 consecutive bytes. The bytes represent a 32 bit string, in either big endian or little endian format, as deter-
mined by the Scale Factor / Endianness line of the PFM header. That string is an IEEE 32 bit floating point number code. Since that's the
same format that most CPUs and compiler use, you can usually just make a program use the bytes directly as a floating point number, after
taking care of the endianness variation.
netpbm documentation PFM Format Description(5)