Sponsored Content
Full Discussion: Extract sequence blocks
Top Forums Shell Programming and Scripting Extract sequence blocks Post 302300928 by solli on Wednesday 25th of March 2009 11:47:35 AM
Old 03-25-2009
Let's say my line is: 123456789123456789123456789

fold gives me:
123456789
123456789
123456789

but I need:
123456789
234567891
345678912
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

How to extract a sequence of n lines from a file

Hi I want to be able to extract a sequence of n lines from a file. ideas, commands and suggestions would be highly appreciated. Thanks (4 Replies)
Discussion started by: 0ktalmagik
4 Replies

2. Shell Programming and Scripting

Extract Pattern Sequence

Dear Collegues I have to extract Some pattern from raw text file using perl The input will be raw text. Pattern to get - Sequence of Capital Letter Words ( e.g. he is working in Center for Perl Studies. He will come tomorrow...) from thos I have to extract sequences like "Center for Perl... (5 Replies)
Discussion started by: jaganadh
5 Replies

3. Shell Programming and Scripting

extract blocks of text from a file

Hi, This is part of a large text file I need to separate out. I'd like some help to build a shell script that will extract the text between sets of dashed lines, write that to a new file using the whole or part of the first text string as the new file name, then move on to the next one and... (7 Replies)
Discussion started by: cajunfries
7 Replies

4. UNIX for Dummies Questions & Answers

Convert 512-blocks to 4k blocks

I'm Unix. I'm looking at "df" on Unix now and below is an example. It's lists the filesystems out in 512-blocks, I need this in 4k blocks. Is there a way to do this in Unix or do I manually convert and how? So for container 1 there is 7,340,032 in size in 512-blocks. What would the 4k block be... (2 Replies)
Discussion started by: rockycj
2 Replies

5. Shell Programming and Scripting

how to split this file into blocks and then send these blocks as input to the tool called Yices?

Hello, I have a file like this: FILE.TXT: (define argc :: int) (assert ( > argc 1)) (assert ( = argc 1)) <check> # (define c :: float) (assert ( > c 0)) (assert ( = c 0)) <check> # now, i want to separate each block('#' is the delimeter), make them separate files, and then send them as... (5 Replies)
Discussion started by: paramad
5 Replies

6. Shell Programming and Scripting

Row blocks to column blocks

Hello, Searched for a while and found some "line-to-column" script. My case is similar but with multiple fields each row: S02 Length Per S02 7043 3.864 S02 54477 29.89 S02 104841 57.52 S03 Length Per S03 1150 0.835 S03 1321 0.96 S03 ... (9 Replies)
Discussion started by: yifangt
9 Replies

7. Shell Programming and Scripting

Extract sequences of bytes from binary for differents blocks

Hello to all, I would like to search sequences of bytes inside big binary file. The bin file contains blocks of information, each block begins is estructured as follow: 1- Each block begins with the hex 32 (1 byte) and ends with FF. After the FF of the last block, it follows 33. 2- Next... (59 Replies)
Discussion started by: Ophiuchus
59 Replies

8. Shell Programming and Scripting

Extract sequence from fasta file

Hi, I want to match the sequence id (sub-string of line starting with '>' and extract the information upto next '>' line ). Please help . input > fefrwefrwef X900 AGAGGGAATTGG AGGGGCCTGGAG GGTTCTCTTC > fefrwefrwef X932 AGAGGGAATTGG AGGAGGTGGAG GGTTCTCTTC > fefrwefrwef X937... (2 Replies)
Discussion started by: ritakadm
2 Replies

9. Shell Programming and Scripting

Blocks of text in a file - extract when matches...

I sat down yesterday to write this script and have just realised that my methodology is broken........ In essense I have..... ----------------------------------------------------------------- (This line really is in the file) Service ID: 12345 ... (7 Replies)
Discussion started by: Bashingaway
7 Replies

10. Shell Programming and Scripting

Extract distinc sequence of letters

Hallo, I need to extract distinct sequence of letters for example from 136 to 193 Files are quite big, so I would prefer not to use "fold -w1" Thank you very much Input file look like this: 1 cttttacctt catgtgtttt tgcagatatt tgttcataat aacatcttct ttttaagtta 61 ttaaaatctt... (4 Replies)
Discussion started by: kamcamonty
4 Replies
MONGOGRIDFS(3)								 1							    MONGOGRIDFS(3)

The MongoGridFS class

INTRODUCTION
Utilities for storing and retrieving files from the database. GridFS is a storage specification all supported drivers implement. Basically, it defines two collections: files, for file metadata, and chunks, for file content. If the file is large, it will automatically be split into smaller chunks and each chunk will be saved as a docu- ment in the chunks collection. Each document in the files collection contains the filename, upload date, and md5 hash. It also contains a unique _id field, which can be used to query the chunks collection for the file's content. Each document in the chunks collection contains a chunk of binary data, a files_id field that matches its file's _id, and the position of this chunk in the overall file. For example, the files document is something like: <?php array("_id" => 123456789, "filename" => "foo.txt", "chunkSize" => 3, "length" => 12); ?> <?php array("files_id" => 123456789, "n" => 0, "data" => new MongoBinData("abc")); array("files_id" => 123456789, "n" => 1, "data" => new MongoBinData("def")); array("files_id" => 123456789, "n" => 2, "data" => new MongoBinData("ghi")); array("files_id" => 123456789, "n" => 3, "data" => new MongoBinData("jkl")); ?> INTER-LANGUAGE COMPATIBILITY You should be able to use any files created by MongoGridFS with any other drivers, and vice versa. However, some drivers expect that all metadata associated with a file be in a "metadata" field. If you're going to be using other languages, it's a good idea to wrap info you might want them to see in a "metadata" field. For example, instead of: <?php $grid->storeFile("somefile.txt", array("date" => new MongoDate())); ?> use something like: <?php $grid->storeFile("somefile.txt", array("metadata" => array("date" => new MongoDate()))); ?> THE MongoGridFS"; FAMILY" MongoGridFS represents the files and chunks collections. MongoGridFS extends MongoCollection, and an instance of MongoGridFS has access to all of MongoCollection methods, which act on the files collection: <?php $grid = $db->getGridFS(); $grid->update(array("filename" => "foo"), $newObj); // update on the files collection ?> Another example of manipulating metadata: <?php // save a file $id = $grid->storeFile("game.tgz"); $game = $grid->findOne(); // add a downloads counter $game->file['downloads'] = 0; $grid->save($game->file); // increment the counter $grid->update(array("_id" => $id), array('$inc' => array("downloads" => 1))); ?> You can also access the chunks collection from an instance of MongoGridFS: <?php $chunks = $grid->chunks; // $chunks is a normal MongoCollection $chunks->insert(array("x" => 4)); ?> There are some methods for MongoGridFS with the same name as MongoCollection methods, that behave slightly differently. For example, Mon- goGridFS.remove(3) will remove any objects that match the criteria from the files collection and their content from the chunks collection. To store something new in GridFS, there are a couple options. If you have a filename, you can say: <?php $grid->storeFile($filename, array("whatever" => "metadata", "you" => "want")); ?> If you have a string of bytes that isn't a file, you can also store that using MongoGridFS.storeBytes(3): <?php $grid->storeBytes($bytes, array("whatever" => "metadata", "you" => "want")); ?> Querying a MongoGridFS collection returns a MongoGridFSCursor, which behaves like a normal MongoCursor except that it returns MongoGridFS- Files instead of associative arrays. MongoGridFSFiles can be written back to disc using MongoGridFSFile.write(3) or retrieved in memory using MongoGridFSFile.getBytes(3). There is currently no method that automatically streams chunks, but it would be fairly easy to write by querying the $grid->chunks collection. MongoGridFSFile objects contain a field file which contains any file metadata. CLASS SYNOPSIS
MongoGridFS extends MongoCollection Fields o public MongoCollection$chunks NULL o protected string$filesName NULL o protected string$chunksName NULL Methods o public MongoGridFS::__construct (MongoDB $db, [string $prefix = "fs"], [mixed $chunks = "fs"]) o public bool MongoGridFS::delete (mixed $id) o public array MongoGridFS::drop (void ) o public MongoGridFSCursor MongoGridFS::find ([array $query = array()], [array $fields = array()]) o public MongoGridFSFile MongoGridFS::findOne ([mixed $query = array()], [mixed $fields = array()]) o public MongoGridFSFile MongoGridFS::get (mixed $id) o public mixed MongoGridFS::put (string $filename, [array $metadata = array()]) o public bool MongoGridFS::remove ([array $criteria = array()], [array $options = array()]) o public mixed MongoGridFS::storeBytes (string $bytes, [array $metadata = array()], [array $options = array()]) o public mixed MongoGridFS::storeFile (string $filename, [array $metadata = array()], [array $options = array()]) o public mixed MongoGridFS::storeUpload (string $name, [array $metadata]) SEE ALSO
oMongoDB core docs on GridFS oLightCube Solutions blog post on saving user uploads oLightCube Solutions blog post on adding metadata to files PHP Documentation Group MONGOGRIDFS(3)
All times are GMT -4. The time now is 02:13 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy