Sponsored Content
Top Forums Shell Programming and Scripting shell script required to convert rows to columns Post 302192519 by summer_cherry on Wednesday 7th of May 2008 05:25:41 AM
Old 05-07-2008
Code:
cat filename  | sed 's/ //g' | nawk 'BEGIN{FS="=";n=1}
{
if($1!="rset")
	a[n$1]=$2
else
{
	a[n$1]=$2
	n=n+1
}
}
END{
print "siteid    spc   rset"
for(i=1;i<=n;i++)
{
	t=sprintf("%ssiteid",i)
	t1=sprintf("%sspc",i)
	t2=sprintf("%srset",i)
	print a[t]"    "a[t1]"   "a[t2]
}
}'

 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

convert columns into rows

hi, Apologies if this has been covered. I have requirement where i have to convert a single column into multiple column. My data will be like this - 2 3 4 5 6 Output required - 2 3 4 5 6 (1 Reply)
Discussion started by: Nishithinfy
1 Replies

2. Shell Programming and Scripting

convert rows to columns

hi, i have the file as below: abc def ghi jkl i want the output as abc,def,ghi,jki please reply, Thanks (4 Replies)
Discussion started by: namitai
4 Replies

3. Shell Programming and Scripting

Converting rows to columns using shell script

I have a script which converts rows to columns. file_name=$1 mailid=$2 #CREATE BACKUP OF ORIGINAL FILE #cp ${file_name}.xlsx ${file_name}_temp.xlsx #tr '\t' '|' < ${file_name}_temp.xlsx > ${file_name}_temp.csv #rm ${file_name}_temp.xlsx pivot_row=`head -1 ${file_name}` sed 1d... (3 Replies)
Discussion started by: andy538
3 Replies

4. Shell Programming and Scripting

Convert columns to rows in perl script

Hi All I want to have a Perl script which convert columns to rows. The Perl should should read the data from input file. Suppose the input file is 7215484 date to date 173.3 A 1.50 2.23 8.45 10.14 2.00 4.50 2.50 31.32 7216154 month to month (3 Replies)
Discussion started by: parthmittal2007
3 Replies

5. Shell Programming and Scripting

Convert few columns to rows

Hi! Does anybody help me in converting following data: INPUT looks like this: 20. 100. 30 200. 40. 400. 50. 100. 60. 200. 70. 400. 80. 200. 150. 210. 30. 100. OUTPUT should look like this: 20. 100. 30 200. 40. 400. 50. 100. 60. 200. 70.... (5 Replies)
Discussion started by: lovelinux
5 Replies

6. Shell Programming and Scripting

Convert rows to columns

I am looking to print the data in columns and after every 3 words it should be a new row. cat example.out | awk 'END { for (i = 0; ++i < m;) print _;print _ }{ _ = _ x ? _ OFS $1 : $1}' m=1| grep -i INNER I am looking to print in a new line after every 3 words. ... (2 Replies)
Discussion started by: lazydev
2 Replies

7. Shell Programming and Scripting

Shell script to convert rows to columns

Hi I have a file having the values like below ---------------------------- .set A col1=”ABC” col2=34 col3=”DEF” col4=”LMN” col5=25 .set A .set B col1=55 col3=”XYZ” col4=”PQR” col5=66 .set B .set C col2=”NNN” (1 Reply)
Discussion started by: Suneel Mekala
1 Replies

8. UNIX for Beginners Questions & Answers

Shell script to convert rows into cloumns

B010215861628 MA 01020 CARRIER B010215861695 MA 01020 CARRIER B010215861709 MA 01020 CARRIER My output is in the above format I want the output to be: (4 Replies)
Discussion started by: Teegela Prathyu
4 Replies

9. Shell Programming and Scripting

Help with script to convert rows to columns

Hello I have a large database with the following structure: Headword=Gloss1;Gloss2;Gloss3 The Glosses are separated by a ; What I need is to reduce the multiple glosses on each row to columns Headword=Gloss1 Headword=Gloss2 Headword=Gloss3 I had written the following script in awk... (5 Replies)
Discussion started by: gimley
5 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
poolstat(1M)															      poolstat(1M)

NAME
poolstat - report active pool statistics SYNOPSIS
poolstat [-p pool-list] [-r rset-list] [interval [count]] poolstat [-p pool-list] [-o format -r rset-list] [interval [count]] The poolstat utility iteratively examines all active pools on the system. It reports statistics based on the selected output mode. poolstat provides options to examine only specified pools and report resource set-specific statistics. Without options, poolstat examines all pools, reports basic statistics for their resource sets, and exits. DISPLAY FORMATS In default output format, poolstat outputs a header line and a line for each pool. The line begins with the pool ID and its name, followed by a column of statistical data for the processor set attached to the pool. The columns are defined as follows: id Pool ID. pool Pool name. rid Resource set id. rset Resource set name. type Resource set type. min Minimum resource set size. max Maximum resource set size. size Current resource set size. used The measure of how much of the resource set is currently is use. This is calculated as the percentage utilization of the resource set multiplied by its size. If resource set has been reconfigured during last sampling interval, this value might be not reported (-). load The absolute representation of the load that is put on the resource set. For the definition of this property see libpool(3LIB). The following options are supported: -o format Report statistics according to the format specification given in format. See DISPLAY FORMATS. The -o option accepts lists as arguments. Items in a list can be either separated by commas or enclosed in quotes and sepa- rated by commas or spaces. You can specify multiple -o options. The format specification is interpreted as the whitespace separated concatenation of all the format option arguments. The -o option must be used in conjunction with the -r option. -p pool-list Report only pools whose names are in the given list. If the -r option is also used, this option selects only resource sets which belong to pools in the given list. Statistics for pools or resource sets are reported in the same order in which pool names are listed on the pool-list. Pool can be specified by name or by ID. The -p option accepts lists as arguments. Items in a pool-list can only be separated by spaces. -r rset-list Report resource set statistics. If the rset-list argument is "all", then all possible resource set types are selected. The -r option accepts lists as arguments. Items in a list can be either separated by commas or enclosed in quotes and sepa- rated by commas or spaces. The following resource set types are supported: all All resource set types pset Processor set The following operands are supported: count The number of times that the statistics are repeated. By default, poolstat reports statistics only once. If neither interval nor count are specified, statistics are reported once. If interval is specified and count is not, statistics are reported indefinitely. interval The sampling interval in seconds. If neither interval nor count are specified, statistics are reported once. If interval is specified and count is not, statistics are reported indefinitely. Example 1: Using poolstat The following example shows the default output from the poolstat utility: % poolstat pset id pool size used load 0 pool_default 4 3.6 6.2 1 pool_admin 4 3.3 8.4 Example 2: Reporting Resource Set Statistics The following example reports resource set statistics. % poolstat -r pset id pool type rid rset min max size used load 0 pool_default pset -1 pset_default 1 65K 2 1.2 8.3 1 pool_admin pset 1 pset_admin 1 1 1 0.4 5.2 2 pool_other pset -1 pset_default 1 65K 2 1.2 8.3 Resource sets attached to multiple pools, as pset_default in the example above, are listed multiple times, once for each pool. Example 3: Restricting the Output to the List of Pools The following example restricts the output to the list of pools % poolstat -p pool_default pset id pool size used load 0 pool_default 8 5.3 10.3 % poolstat -p 'pool_admin pool_default' pset id pool size used load 1 pool_admin 6 4.3 5.3 0 pool_default 2 1.9 2.0 % poolstat -r all -p 'pool_admin pool_default' id pool type rid rset min max size used load 1 pool_admin pset 1 pset_admin 1 1 1 0.9 2.3 2 pool_default pset -1 pset_default 1 65K 2 2.0 2.0 Example 4: Customizing Output The following example customizes output: % poolstat -r -o pool,rset,size,load pool rset size load pool_default pset_default 4 4.5 pool_admin pset_admin 4 2.1 The following exit values are returned: 0 Successful completion. 1 An error occurred. 2 Invalid command line options were specified. See attributes(5) for descriptions of the following attributes: +-----------------------------+-----------------------------+ | ATTRIBUTE TYPE | ATTRIBUTE VALUE | +-----------------------------+-----------------------------+ |Availability |SUNWpool | +-----------------------------+-----------------------------+ |Stability |Evolving | +-----------------------------+-----------------------------+ libpool(3LIB), attributes(5) The system ids associated with resources can change after the system reboots or the resource configuration is altered. 15 Feb 2005 poolstat(1M)
All times are GMT -4. The time now is 06:41 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy