Sponsored Content
Top Forums Shell Programming and Scripting Read from text file;format and print output Post 302784299 by maddy.san on Friday 22nd of March 2013 01:17:50 AM
Old 03-22-2013
Read from text file;format and print output

Hi Following is the assumed input...
Code:
Symmetrix ID        : 12345

Originator Port wwn : 123456789
User-generated Name : 123456789/123456789

Sym Dev  Dir:P                                            LUN
------  -----  -----------------------  ----  ---  ---- ----  ----  -------
1234     8A:1  Not Visible                 0    0    61  N/A  (M)     17261
5678     8C:1  Not Visible                 0    0    75  N/A  (M)     25892
9123     8C:1  Not Visible                 0    0    80  N/A  (M)    153563
4567     8A:1  Not Visible                 0    0    67  N/A          219
Symmetrix ID        : 12345

Originator Port wwn : 123456789
User-generated Name : 123456789/123456789

Sym Dev  Dir:P                                            LUN
------  -----  -----------------------  ----  ---  ---- ----  ----  -------
1234     8A:1  Not Visible                 0    0    61  N/A  (M)     17261
5678     8C:1  Not Visible                 0    0    75  N/A  (M)     25892

Symmetrix ID        : 12345

Originator Port wwn : 123456789
User-generated Name : 123456789/123456789

Sym Dev  Dir:P                                            LUN
------  -----  -----------------------  ----  ---  ---- ----  ----  -------
1234     8A:1  Not Visible                 0    0    61  N/A  (M)     17261
5678     8C:1  Not Visible                 0    0    75  N/A  (M)     25892
9123     8C:1  Not Visible                 0    0    80  N/A  (M)    153563


I need output as below:
Code:
Originator Port WWN        Sym Dev             Dir:P

123456789        1234,5678,9123,4567    8A:1,8C1,8A1,8C1
123456789        1234,5678        8A:1,8C1
123456789        1234,5678,9123        8A:1,8C1,8A1


Please help .tried using awk but dint help

Last edited by Franklin52; 03-22-2013 at 05:00 AM.. Reason: Please use code tags for data and code samples
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

format output from while read line

I have an output that I get from while read, I want to display it as the following, please help. Original output from while read line loop: This is my client=1 client version=2.3.4 OS version=4.5 This is my client=2 client version=1.5.6 OS version=6.7 I want it to look like this with... (7 Replies)
Discussion started by: dala
7 Replies

2. Shell Programming and Scripting

Net::SSH::Perl ...... how to print the output in a proper format

Hi Guys, my $cmd = "ls -l"; #........ {or let it be as # my $cmd= "ls"; } my $ssh = Net::SSH::Perl->new($host); $ssh->login($user, $pass); my($stdout, $stderr, $exit) = $ssh->cmd("$cmd"); print $stdout; the script works fine, but i am unable to see the output getting displayed in a... (7 Replies)
Discussion started by: gsprasanna
7 Replies

3. Shell Programming and Scripting

Dynamic output file generation using a input text file with predefined output format

Hi, I have two files , one file with data file with attributes that need to be sent to another file to generate a predefined format. Example: File.txt AP|{SSHA}VEEg42CNCghUnGhCVg== APVG3|{SSHA}XK|"password" AP3|{SSHA}XK|"This is test" .... etc --------- test.sh has... (1 Reply)
Discussion started by: hudson03051nh
1 Replies

4. Shell Programming and Scripting

read the text file and print the content character by character..

hello all i request you to give the solution for the following problem.. I want read the text file.and print the contents character by character..like if the text file contains google means..i want to print g go goo goog googl google like this Using unix Shell scripting... without using... (1 Reply)
Discussion started by: samupnl
1 Replies

5. Shell Programming and Scripting

Read a text file and print the content..

hello all i request you to give the solution for the following problem.. I want read the text file.and print the contents character by character..like if the text file contains google means..i want to print g go goo goog googl google like this Using unix Shell scripting... ... (7 Replies)
Discussion started by: samupnl
7 Replies

6. Shell Programming and Scripting

Print output and read input on same line

How do I print output and read input on the same line in ksh? echo Hello, what is your name? read name (1 Reply)
Discussion started by: robin_simple
1 Replies

7. Programming

Read text from file and print each character in separate line

performing this code to read from file and print each character in separate line works well with ASCII encoded text void preprocess_file (FILE *fp) { int cc; for (;;) { cc = getc (fp); if (cc == EOF) break; printf ("%c\n", cc); } } int main(int... (1 Reply)
Discussion started by: khaled79
1 Replies

8. Shell Programming and Scripting

Read in search strings from text file, search for string in second text file and output to CSV

Hi guys, I have a text file named file1.txt that is formatted like this: 001 , ID , 20000 002 , Name , Brandon 003 , Phone_Number , 616-234-1999 004 , SSNumber , 234-23-234 005 , Model , Toyota 007 , Engine ,V8 008 , GPS , OFF and I have file2.txt formatted like this: ... (2 Replies)
Discussion started by: An0mander
2 Replies

9. UNIX for Beginners Questions & Answers

Read line and print output

need help to print the below .. Content of file looks like below .. SCHEMA1. TABLE1 SCHEMA2. TABLE2 SCHEMA3. TABLE3 read lines from above file and print o/p as below print output like read 1st line and print SELECT SCHEMA1.TABLE1 print output like read 2st line and print ... (4 Replies)
Discussion started by: rocking77
4 Replies

10. UNIX for Beginners Questions & Answers

Convert rows to column and print output in required format

Hi All, i am trying to print the solaris 11 packages in below required format, But i am unable to do that. Current ouput : root@abc# pkginfo -l | egrep '(BASEDIR|NAME|VERSION)' | awk '{print}' NAME: QLogic 570x/571x Gigabit Ethernet Driver VERSION: 11.11,REV=2009.11.11 ... (7 Replies)
Discussion started by: balu1234
7 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 05:14 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy