"are you billy_smith ?"
replace with
"are you billy_smith ?
my name is billy_smith"
how to fetch the name "billy_smith" and using it later
I need sed script to do this, any one can help? Thanks (6 Replies)
If the string is of the pattern XxxXyzAbc...
The expected out put from sed has to be Xxx Xyz Abc ...
eg: if the string is QcfEfQfs, then the expected output is Qcf Ef Efs.
If i try to substitute the pattern with space then the sed will replace the character or pattern with space,... (1 Reply)
Hi,
Is there a way in Korn Shell that I can run multiple commands stored as a semi-colon separated string, e.g.,
# vs="echo a; echo b;"
# $vs
a; echo b;
I want to be able to store commands in a variable, then run all of it once and pipe the whole output to another program without using... (2 Replies)
Hi:
I have 2 files: teststring.txt and a tempfile.txt
teststring file contains:
s/Primary Ins./\n1/g
I'm trying to search for "Primary Ins." string in tempfile. For every "Primary Ins." string that is found, a new line is inserted and put in number 1. Then, write out the newfile... (7 Replies)
here is what i want to achieve... consider a file contains below contents. the file size is large about 60mb
cat dump.sql
INSERT INTO `table1` (`id`, `action`, `date`, `descrip`, `lastModified`) VALUES (1,'Change','2011-05-05 00:00:00','Account Updated','2012-02-10... (10 Replies)
Hi,
I would like to know how, using sed, be able to insert contents of file2 in file1 after say the second occurrence of a given string? e.g.
> cat file1
banana
apple
orange
apple
banana
pear
tangerine
apple
> cat file2
I don't like apples
What would be the sed command to insert... (5 Replies)
I need to read a text file and insert a string every n lines, but also have the line counter restart when I come across a header string.
Line repeating working every 3 lines using code:
sed '0~3 s/$/\nINSERT/g' < INPUT/PATH/FILE_NAME.txt > OUTPUT/PATH/FILE_NAME.txt
I cannot seem to find... (1 Reply)
Dear all,
I would like to insert N blankspaces in front of a string using sed command
To give an example (N=10), I tried that code:
$ echo "abcd" | sed 's/^/ \{10,\}&/'
but I failed, by obtaining that result:
{10,}abcd
Any help would be greatly appreciated,
Thanks in advance,... (18 Replies)
i am having file like this
#!/bin/bash
read -p 'Username: ' uservar
match='<color="red" />'
text='this is only a test
so please be patient
<color="red" />'
echo "$text" | sed "s/$match/&$uservar\g"
so desireble output what i want is if user type MARIA
this is only a test
so please... (13 Replies)
Discussion started by: tomislav91
13 Replies
LEARN ABOUT DEBIAN
mongodb::gridfs
MongoDB::GridFS(3pm) User Contributed Perl Documentation MongoDB::GridFS(3pm)NAME
MongoDB::GridFS - A file storage utility
SYNOPSIS
use MongoDB::GridFS;
my $grid = $database->get_gridfs;
my $fh = IO::File->new("myfile", "r");
$grid->insert($fh, {"filename" => "mydbfile"});
There are two interfaces for GridFS: a file-system/collection-like interface (insert, remove, drop, find_one) and a more general interface
(get, put, delete). Their functionality is the almost identical (get, put and delete are always safe ops, insert, remove, and find_one are
optionally safe), using one over the other is a matter of preference.
SEE ALSO
Core documentation on GridFS: <http://dochub.mongodb.org/core/gridfs>.
ATTRIBUTES
chunk_size
The number of bytes per chunk. Defaults to 1048576.
prefix
The prefix used for the collections. Defaults to "fs".
files
Collection in which file metadata is stored. Each document contains md5 and length fields, plus user-defined metadata (and an _id).
chunks
Actual content of the files stored. Each chunk contains up to 4Mb of data, as well as a number (its order within the file) and a files_id
(the _id of the file in the files collection it belongs to).
METHODS
get($id)
my $file = $grid->get("my file");
Get a file from GridFS based on its _id. Returns a MongoDB::GridFS::File.
put($fh, $metadata)
my $id = $grid->put($fh, {filename => "pic.jpg"});
Inserts a file into GridFS, adding a MongoDB::OID as the _id field if the field is not already defined. This is a wrapper for
"MongoDB::GridFS::insert", see that method below for more information.
Returns the _id field.
delete($id)
$grid->delete($id)
Removes the file with the given _id. Will die if the remove is unsuccessful. Does not return anything on success.
find_one ($criteria?, $fields?)
my $file = $grid->find_one({"filename" => "foo.txt"});
Returns a matching MongoDB::GridFS::File or undef.
remove ($criteria?, $options?)
$grid->remove({"filename" => "foo.txt"});
Cleanly removes files from the database. $options is a hash of options for the remove. Possible options are:
just_one If true, only one file matching the criteria will be removed.
safe If true, each remove will be checked for success and die on failure.
This method doesn't return anything.
insert ($fh, $metadata?, $options?)
my $id = $gridfs->insert($fh, {"content-type" => "text/html"});
Reads from a file handle into the database. Saves the file with the given metadata. The file handle must be readable. $options can be
"{"safe" =" true}>, which will do safe inserts and check the MD5 hash calculated by the database against an MD5 hash calculated by the
local filesystem. If the two hashes do not match, then the chunks already inserted will be removed and the program will die.
Because "MongoDB::GridFS::insert" takes a file handle, it can be used to insert very long strings into the database (as well as files).
$fh must be a FileHandle (not just the native file handle type), so you can insert a string with:
# open the string like a file
my $basic_fh;
open($basic_fh, '<', $very_long_string);
# turn the file handle into a FileHandle
my $fh = FileHandle->new;
$fh->fdopen($basic_fh, 'r');
$gridfs->insert($fh);
drop
@files = $grid->drop;
Removes all files' metadata and contents.
all
@files = $grid->all;
Returns a list of the files in the database.
AUTHOR
Kristina Chodorow <kristina@mongodb.org>
perl v5.14.2 2011-09-07 MongoDB::GridFS(3pm)