Sponsored Content
Full Discussion: How to format output
Top Forums Shell Programming and Scripting How to format output Post 302294890 by Whiteboard on Friday 6th of March 2009 05:18:14 AM
Old 03-06-2009
Code:
$ cat samplefile
21608 10-20-2007 148 Al's Appliance and Sport 2837
Greenway Fillmore FL 33336 Valerie Iron
 
21610 10-20-2007 356 Ferguson's 382
Wildwood Northfield FL 33146 Juan Gas Range
 
$ head -2 samplefile| tr "\n" " "
21608 10-20-2007 148 Al's Appliance and Sport 2837 Greenway Fillmore FL 33336 Valerie Iron

The above code will give the output in a single line...
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

ls output format

below is the output is ls -l -rw-r--r-- 1 tonyt staff 3212 Apr 17 1999 file1 -rw-r--r-- 1 tonyt staff 4541 Mar 3 21:08 file2 why the date format is not the same? (6 Replies)
Discussion started by: tonyt
6 Replies

2. Shell Programming and Scripting

format output

I have a text file that I want a script to parse and grab only the relavent stuff. No idea where to start.. This is the text file.212 0.00000 ? -> (multicast) ETHER Type=2000 (Unknown), size = 344 bytes 0: 0100 0ccc cccc 000b 5f95 0fbe 014a aaaa ........_....J..... (7 Replies)
Discussion started by: Tornado
7 Replies

3. Shell Programming and Scripting

capturing output from top and format output

Hi all, I'd like to capture the output from the 'top' command to monitor my CPU and Mem utilisation.Currently my command isecho date `top -b -n1 | grep -e Cpu -e Mem` I get the output in 3 separate lines.Tue Feb 24 15:00:03 Cpu(s): 3.4% us, 8.5% sy .. .. Mem: 1011480k total, 226928k used, ....... (4 Replies)
Discussion started by: new2ss
4 Replies

4. Shell Programming and Scripting

Help in Getting specified output format

Hi all, I have input text file of this format objectclass:endeavor pid:12345 postalAddress:379 PROSPECT ST street:STE B l:TORRINGTON st:CT postalCode:067905238 telephoneNumber:9999999999... (2 Replies)
Discussion started by: pintoo
2 Replies

5. UNIX for Advanced & Expert Users

format df -k output

i am running df -k command on aix machine. i got the output like this. i need to store into file and send that file into microsoft excel.i need to allign properly. Filesystem 512 blocks Free % Used Iused %Iused Mounted on /dev/hd4 262144 126488 52% ... (9 Replies)
Discussion started by: wintercoat
9 Replies

6. 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

7. UNIX for Dummies Questions & Answers

Format Output

Hello Learned People, Good evening. I have absolutely no idea as how to do this & I admit that I do not know anything in unix. I must learn this one of these days. Im a help desk incharge today & someone gave me this file to be formatted & I have a file like this. vi NewFile.txt 232... (8 Replies)
Discussion started by: RTAN
8 Replies

8. Shell Programming and Scripting

Script to generate Excel file or to SQL output data to Excel format/tabular format

Hi , i am generating some data by firing sql query with connecting to the database by my solaris box. The below one should be the header line of my excel ,here its coming in separate row. TO_CHAR(C. CURR_EMP_NO ---------- --------------- LST_NM... (6 Replies)
Discussion started by: dani1234
6 Replies

9. Shell Programming and Scripting

Format with output

I have written some scripts that resulted in the table below (Column1 is ITEM, Column2 is Group, Column3 is Category and Column4 is Quantity) but I want the output in another format: Input: K123 X CATA 3 K123 Y CATA 4 K123 Z CATA 2 K123 X CATB 5 K123 Y CATB 2 K123 Z CATB 2 B65 M CATB... (7 Replies)
Discussion started by: aydj
7 Replies

10. Shell Programming and Scripting

Format output

Hello Team, I have the following details in a txt file (please note the spaces and tabs) C1 C2 C3 ------------------ --------------- ------------- abc, xyz 2 8 pqr 2 ... (9 Replies)
Discussion started by: H squared
9 Replies
Elements(3pm)						User Contributed Perl Documentation					     Elements(3pm)

NAME
Chemistry::Elements - Perl extension for working with Chemical Elements SYNOPSIS
use Chemistry::Elements qw(get_name get_Z get_symbol); # the constructor can use different input $element = Chemistry::Elements->new( $atomic_number ); $element = Chemistry::Elements->new( $chemical_symbol ); $element = Chemistry::Elements->new( $element_name ); # you can make up your own attributes by specifying # a method (which is really AUTOLOAD) $element->molar_mass(22.989) #sets the attribute $MM = $element->molar_mass #retrieves the value DESCRIPTION
There are two parts to the module: the object stuff and the exportable functions for use outside of the object stuff. The exportable functions are discussed in EXPORTABLE FUNCTIONS. Chemistry::Elements provides an easy, object-oriented way to keep track of your chemical data. Using either the atomic number, chemical symbol, or element name you can construct an Element object. Once you have an element object, you can associate your data with the object by making up your own methods, which the AUTOLOAD function handles. Since each chemist is likely to want to use his or her own data, or data for some unforesee-able property, this module does not try to be a repository for chemical data. The Element object constructor tries to be as flexible as possible - pass it an atomic number, chemical symbol, or element name and it tries to create the object. # the constructor can use different input $element = Chemistry::Elements->new( $atomic_number ); $element = Chemistry::Elements->new( $chemical_symbol ); $element = Chemistry::Elements->new( $element_name ); once you have the object, you can define your own methods simply by using them. Giving the method an argument (others will be ignored) creates an attribute with the method's name and the argument's value. # you can make up your own attributes by specifying # a method (which is really AUTOLOAD) $element->molar_mass(22.989) #sets the attribute $MM = $element->molar_mass #retrieves the value The atomic number, chemical symbol, and element name can be retrieved in the same way. $atomic_number = $element->Z; $name = $element->name; $symbol = $element->symbol; These methods can also be used to set values, although changing any of the three affects the other two. $element = Chemistry::Elements->new('Lead'); $atomic_number = $element->Z; # $atomic_number is 82 $element->Z(79); $name = $element->name; # $name is 'Gold' Instance methods new( Z | SYMBOL | NAME ) Create a new instance from either the atomic number, symbol, or element name. can( METHOD [, METHOD ... ] ) Returns true if the package or object can respond to METHOD. This distinguishes between class and instance methods. Z Return the atomic number of the element. name Return the name of the element. symbol Return the symbol of the element. Exportable functions These functions can be exported. They are not exported by default. At the moment, only the functional interface supports multi-language names. get_symbol( NAME|Z ) This function attempts to return the symbol of the chemical element given either the chemical symbol, element name, or atmoic number. The function does its best to interpret inconsistent input data (e.g. chemcial symbols of mixed and single case). use Chemistry::Elements qw(get_symbol); $name = get_symbol('Fe'); #$name is 'Fe' $name = get_symbol('fe'); #$name is 'Fe' $name = get_symbol(26); #$name is 'Fe' $name = get_symbol('Iron'); #$name is 'Fe' $name = get_symbol('iron'); #$name is 'Fe' If no symbol can be found, nothing is returned. Since this function will return the symbol if it is given a symbol, you can use it to test whether a string is a chemical symbol (although you have to play some tricks with case since get_symbol will try its best despite the case of the input data). if( lc($string) eq lc( get_symbol($string) ) ) { #stuff } You can modify the symbols (e.g. you work for UCal ;) ) by changing the data at the end of this module. get_name( SYMBOL|NAME|Z [, LANGUAGE] ) This function attempts to return the name the chemical element given either the chemical symbol, element name, or atomic number. The function does its best to interpret inconsistent input data (e.g. chemcial symbols of mixed and single case). $name = get_name('Fe'); #$name is 'Iron' $name = get_name('fe'); #$name is 'Iron' $name = get_name(26); #$name is 'Iron' $name = get_name('Iron'); #$name is 'Iron' $name = get_name('iron'); #$name is 'Iron' If there is no Z can be found, nothing is returned. Since this function will return the name if it is given a name, you can use it to test whether a string is a chemical element name (although you have to play some tricks with case since get_name will try its best despite the case of the input data). if( lc($string) eq lc( get_name($string) ) ) { #stuff } You can modify the names (e.g. for different languages) by changing the data at the end of this module. get_Z( SYMBOL|NAME|Z ) This function attempts to return the atomic number of the chemical element given either the chemical symbol, element name, or atomic number. The function does its best to interpret inconsistent input data (e.g. chemcial symbols of mixed and single case). $name = get_Z('Fe'); #$name is 26 $name = get_Z('fe'); #$name is 26 $name = get_Z(26); #$name is 26 $name = get_Z('Iron'); #$name is 26 $name = get_Z('iron'); #$name is 26 If there is no Z can be found, nothing is returned. Since this function will return the Z if it is given a Z, you can use it to test whether a string is an atomic number. You might want to use the string comparison in case the $string is not a number (in which case the comparison will be false save for the case when $string is undefined). if( $string eq get_Z($string) ) { #stuff } The package constructor automatically finds the largest defined atomic number (in case you add your own heavy elements). AUTOLOADing methods You can pseudo-define additional methods to associate data with objects. For instance, if you wanted to add a molar mass attribute, you simply pretend that there is a molar_mass method: $element->molar_mass($MM); #add molar mass datum in $MM to object Similiarly, you can retrieve previously set values by not specifying an argument to your pretend method: $datum = $element->molar_mass(); #or without the parentheses $datum = $element->molar_mass; If a value has not been associated with the pretend method and the object, the pretend method returns nothing. I had thought about providing basic data for the elements, but thought that anyone using this module would probably have their own data. If there is an interest in canned data, perhaps I can provide mine :) Localization support XXX: Fill this stuff in later. For now see the test suite TO DO
I would like make this module easily localizable so that one could specify other names or symbols for the elements (i.e. a different language or a different perspective on the heavy elements). If anyone should make changes to the data, i would like to get a copy so that i can include it in future releases :) SOURCE AVAILABILITY
The source for this module is in Github: git://github.com/briandfoy/chemistry--elements.git AUTHOR
brian d foy, "<bdfoy@cpan.org>" COPYRIGHT AND LICENSE
Copyright (c) 2000-2008 brian d foy. All rights reserved. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. perl v5.10.0 2009-08-10 Elements(3pm)
All times are GMT -4. The time now is 10:20 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy