Sponsored Content
Full Discussion: Keeping the number intact
Top Forums Shell Programming and Scripting Keeping the number intact Post 302587892 by birei on Friday 6th of January 2012 07:53:03 AM
Old 01-06-2012
Hi kristinu,

You may need the GNU version of 'sed' to use next command:
Code:
$ ... | sed 's/\([0-9]\+\(\.[0-9]\+\)\?\)/ \1 /g'
n 02 -z 30 -dsr 65 -terr 0.50 -dc 0.05 - 4 x 3 smp.cmd
n 02 -z 30 -dsr 65 -terr 0.50 -dc 0.01 - 8 x 6 smp.cmd
n 02 -z 30 -dsr 65 -terr 0.50 -dc 0.006 - 8 x 6 smp.cmd
n 02 -z 30 -dsr 65 -terr 0.50 -dc 0.008 - 8 x 6 smp.cmd

Regards,
Birei
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Grab terms leaving spacings intact

Hi All, I have an input below. I would want to print the 2nd to 5th term leaving the same number of spaces in between each term to be intact. Here in the example, there are 4 spacings between term " ABC " and " 111 ", and i tried the below awk codes but they don;t work. Can anybody give me... (3 Replies)
Discussion started by: Raynon
3 Replies

2. Shell Programming and Scripting

Removing sections and leaving separators intact

I have an awk script like below function abs(val) { return val > 0 ? val : -val } # 1. Main input loop, executed for each line of input BEGIN { RS = ORS = ">" } { if ( NF > 2 ) { if ( abs( $1 - $(NF-2) ) < 40 ) { print } } } The input file is something like... (2 Replies)
Discussion started by: kristinu
2 Replies

3. Shell Programming and Scripting

Help with file editing while keeping file format intact

Hi, I am having a file which is fix length and comma seperated. And I want to replace values for one column. I am reading file line by line in variable $LINE and then replacing the string. Problem is after changing value and writing new file temp5.txt, formating of original file is getting... (8 Replies)
Discussion started by: Mruda
8 Replies

4. UNIX for Dummies Questions & Answers

sort by keeping the headings intact?

Hi all, I have a file with 3 columns separated by space. Each column has a heading. I want to sort according to the values in the 2nd column (ascending order). Ex. Name rank direction goory 0.05 --+ laby 0.0006 --- namy 0.31 -+- ....etc. Output should be Name rank direction laby... (3 Replies)
Discussion started by: Unilearn
3 Replies

5. Shell Programming and Scripting

Need to Zip files three years old or longer but leave folder structure intact

Hi all, Hello everyone, my first post here :). I tried to search the forum but I didn't find exactly what I was looking for... I need to zip/tar files across entire filesystem which are more 3+ years old but leave folder structure intact. If the script locates tar/zip files they are more... (1 Reply)
Discussion started by: sashruby
1 Replies

6. Shell Programming and Scripting

Remove last few characters in a file but keeping Header and trailer intact

Hi All, I am trying write a simple command using AWK and SED to this but without any success. Here is what I am using: head -1 test1.txt>test2.txt|sed '1d;$d' test1.txt|awk '{print substr($0,0,(length($0)-2))}' >>test2.txt|tail -1 test1.txt>>test2.txt Input: Header 1234567 abcdefgh... (2 Replies)
Discussion started by: nvuradi
2 Replies

7. Shell Programming and Scripting

Grab data between 2 keywords any do an array operation and write the file intact

Hi Unix Gurus, I need to grep for a block that is between a start and end keyword and then in between I need to find and replace a keyword. for eg: I need to search between Test = 000; and Test = 000; and find K9 and replace with M9 INPUT FILE Define { Replace = K9; Test =... (6 Replies)
Discussion started by: naveen@
6 Replies

8. Shell Programming and Scripting

Remove duplicates by keeping the order intact

Hello friends, I have a file with duplicate lines. I could eliminate duplicate lines by running sort <file> |uniq >uniq_file and it works fine BUT it changes the order of the entries as it we did "sort". I need to remove duplicates and also need to keep the order/sequence of entries. I... (1 Reply)
Discussion started by: magnus29
1 Replies

9. Shell Programming and Scripting

Printing the output of a gzip command intact

how can i get the printf command or the echo command to print the data that are inbetween the first and the last quotes? #!/bin/sh printf '%s\n' "^_<8b>^H^@U<8c>MX^@^Cí=ÙzÚH<97>×ð^Teìn<8c>Ób_<9d><9f>dXd<9b>^N^F7<82>8qâÎ'^K^Y^T<83>D<90>°M^Lý^Hó^Fs5w3ß|s5/ÐýbS%©<84>^DBH... (4 Replies)
Discussion started by: SkySmart
4 Replies

10. Shell Programming and Scripting

How to control grep output intact for each matching line?

I have multiple (~80) files (some can be as big as 30GB of >1 billion of lines!) to grep on a pattern, and piped the match to a single file. I have a 96-core machine so that each grep job was sent to the background to speed up the search: file1.tab chr1A_part1 123241847 123241848... (6 Replies)
Discussion started by: yifangt
6 Replies
Data::StreamDeserializer(3pm)				User Contributed Perl Documentation			     Data::StreamDeserializer(3pm)

NAME
Data::StreamDeserializer - non-blocking deserializer. SYNOPSIS
my $sr = new Data::StreamDeserializer data => $very_big_dump; ... somewhere unless($sr->next) { # deserialization hasn't been done yet } ... if ($sr->next) { # deserialization has been done ... if ($sr->is_error) { printf "%s ", $sr->error; printf "Unparsed string tail: %s ", $sr->tail; } my $result = $sr->result; # first deserialized object my $result = $sr->result(first); # the same my $results = $sr->result('all'); # all deserialized objects # (ARRAYREF) } # stream deserializer $sr = new Data::StreamDeserializer; while(defined (my $block = read_next_data_block)) { $sr->next($block); ... } $sr->next(undef); # eof signal until ($sr->next) { ... do something } # all data were parsed DESCRIPTION
Sometimes You need to deserialize a lot of data. If You use 'eval' (or Safe->reval, etc) it can take You too much time. If Your code is executed in event machine it can be inadmissible. So using the module You can deserialize Your stream progressively and do something else between deserialization itearions. Recognized statements HASHES { something } ARRAYS [ something ] REFS something [ ARRAY ] { HASH } Regexps qr{something} SCALARS "something" 'something' q{something} qq{something} METHODS
new Creates new deserializer. It can receive a few named arguments: block_size The size of block which will be serialized in each 'next' cycle. Default value is 512 bytes. data If You know (have) all data to deserialize before constructing the object, You can use this argument. NOTE: You must not use the function part or next with arguments if You used this argument. block_size Set/get the same field. part Append a part of input data to serialize. If there is no argument (or undef), deserializer will know that there will be no data in the future. next Processes to parse next block_size bytes. Returns TRUE if an error was detected or all input datas were parsed. next_object The same as next but returns true after new object is found. Drop previous results. For example You have the string: $str = "1, 2, [ 0, 1 ], { 'a' => 'b' }"; You can extract objects: my $dsr = new Data::StreamDeserializer data => $str; 1 until $dsr->next_object; my $first = $dsr->result; # scalar: 1 1 until $dsr->next_object; my $second = $dsr->result; # scalar: 2 1 until $dsr->next_object; my $third = $dsr->result; # arrayref: [ 0, 1 ] 1 until $dsr->next_object; my $third = $dsr->result; # hashref: { 'a' => 'b' } skip_divider If You have a string: Object Object Object (there are no dividers between objects), You can call skip_divider after fetching the next object. Example: $str = "1 2 [ 0, 1 ]{ 'a' => 'b' }"; my $dsr = new Data::StreamDeserializer data => $str; 1 until $dsr->next_object; my $first = $dsr->result; # scalar: 1 $dsr->skip_divider; 1 until $dsr->next_object; my $second = $dsr->result; # scalar: 2 $dsr->skip_divider; 1 until $dsr->next_object; my $third = $dsr->result; # arrayref: [ 0, 1 ] Important: You can't skip dividers inside nested object. The function will croak if You call it in the point that isn't between objects. is_error Returns TRUE if an error was detected. error Returns error string. tail Returns unparsed data. result Returns result of parsing. By default the function returns only the first parsed object. You can call the function with argument 'all' to get all parsed objects. In this case the function will receive ARRAYREF. is_done Returns TRUE if all input data were processed or an error was found. If You didn't call part without arguments, and didn't call next or next_object with undef the function could return TRUE only if an error occured. PRIVATE METHODS
_push_error Pushes error into deserializer's error stack. SEE ALSO
DATA::StreamSerializer BENCHMARKS
This module is almost fully written using XS/C language. So it works a bit faster or slowly than CORE::eval. You can try a few scripts in benchmark/ directory. There are a few test arrays in this directory. Here are a few test results of my system. Array which contains 100 hashes: It works faster than eval: $ perl benchmark/ds_vs_eval.pl -n 1000 -b 512 benchmark/tests/01_100x10 38296 bytes were read First deserializing by eval... done First deserializing by Data::DeSerializer... done Check if deserialized objects are same... done Starting 1000 iterations for eval... done (3.755 seconds) Starting 1000 iterations for Data::StreamDeserializer... done (3.059 seconds) Eval statistic: 1000 iterations were done maximum deserialization time: 0.0041 seconds minimum deserialization time: 0.0035 seconds average deserialization time: 0.0036 seconds StreamDeserializer statistic: 1000 iterations were done 75000 SUBiterations were done 512 bytes in one block in one iteration maximum deserialization time: 0.0045 seconds minimum deserialization time: 0.0028 seconds average deserialization time: 0.0029 seconds average subiteration time: 0.00004 seconds Array which contains 1000 hashes: It works slowly than eval: $ perl benchmark/ds_vs_eval.pl -n 1000 -b 512 benchmark/tests/02_1000x10 355623 bytes were read First deserializing by eval... done First deserializing by Data::DeSerializer... done Check if deserialized objects are same... done Starting 1000 iterations for eval... done (43.920 seconds) Starting 1000 iterations for Data::StreamDeserializer... done (71.668 seconds) Eval statistic: 1000 iterations were done maximum deserialization time: 0.0490 seconds minimum deserialization time: 0.0416 seconds average deserialization time: 0.0426 seconds StreamDeserializer statistic: 1000 iterations were done 689000 SUBiterations were done 512 bytes in one block in one iteration maximum deserialization time: 0.0773 seconds minimum deserialization time: 0.0656 seconds average deserialization time: 0.0690 seconds average subiteration time: 0.00010 seconds You can see, that one block is parsed in a very short time period. So You can increase block_size value to reduce total parsing time. If block_size is equal string size the module works two times faster than eval: $ perl benchmark/ds_vs_eval.pl -n 1000 -b 355623 benchmark/tests/02_1000x10 355623 bytes were read First deserializing by eval... done First deserializing by Data::DeSerializer... done Check if deserialized objects are same... done Starting 1000 iterations for eval... done (44.456 seconds) Starting 1000 iterations for Data::StreamDeserializer... done (19.702 seconds) Eval statistic: 1000 iterations were done maximum deserialization time: 0.0474 seconds minimum deserialization time: 0.0423 seconds average deserialization time: 0.0431 seconds StreamDeserializer statistic: 1000 iterations were done 1000 SUBiterations were done 355623 bytes in one block in one iteration maximum deserialization time: 0.0179 seconds minimum deserialization time: 0.0168 seconds average deserialization time: 0.0171 seconds average subiteration time: 0.01705 seconds AUTHOR
Dmitry E. Oboukhov, <unera@debian.org> COPYRIGHT AND LICENSE
Copyright (C) 2011 by Dmitry E. Oboukhov This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.10.1 or, at your option, any later version of Perl 5 you may have available. VCS
The project is placed in my git repo. See here: http://git.uvw.ru/?p=data-stream-deserializer;a=summary <http://git.uvw.ru/?p=data-stream- deserializer;a=summary> perl v5.14.2 2011-02-07 Data::StreamDeserializer(3pm)
All times are GMT -4. The time now is 02:40 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy