Sponsored Content
Top Forums Shell Programming and Scripting awk printf for user defined variables Post 302138530 by aigles on Tuesday 2nd of October 2007 08:07:55 AM
Old 10-02-2007
One way:
Code:
find / -type d -name $Database -exec du -sk {} \; 2>/dev/null |
awk -v Db=$Database '{
sum += $1
}
END {
printf("%10s\t%20s\n",Db,sum) }'

Jean-Pierre.
 

10 More Discussions You Might Find Interesting

1. Programming

pre defined variables

Hi First I want to explain the scenerio : In my project I want to control the printing of some messages. Thats why I use #ifdef MESSAGE ------------print message-------------- #endif And when I compile the program with -DMESSAGE option, it shows all message and without -DMESSAGE option... (7 Replies)
Discussion started by: sumsin
7 Replies

2. Shell Programming and Scripting

Return an array of strings from user defined function in awk

Hello Friends, Is it possible to return an array from a user defined function in awk ? example: gawk ' BEGIN{} { catch_line = my_function(i) print catch_line print catch_line print catch_line } function my_function(i) { print "echo" line= "awk" line= "gawk"... (2 Replies)
Discussion started by: user_prady
2 Replies

3. Shell Programming and Scripting

using AWK printf with userdefine variables

seems simple but i've not been successfull in adding the value of a Variable to a every line of a file using AWK & printf i've come up with the following, but it's not working.:mad: --- mydatafile.dat e.g. of data in file: cau_actvty_fa_lrf.ksh fan_soco_fa.ksh ny_sum_lst.ksh... (4 Replies)
Discussion started by: danmauer
4 Replies

4. Shell Programming and Scripting

Crontab jobs don't see variables defined in /etc/profile

Is it true that Crontab jobs don't see variables defined in /etc/profile? How to get around that? (4 Replies)
Discussion started by: proactiveaditya
4 Replies

5. Shell Programming and Scripting

User defined functions in awk

Hi; Is der ne to to use user defined functions for the values in awk find $1 -type f -ls | nawk '{{print "|"$3"|"$5"|"$6"|"$8"|"$9"|"$10"|"} for(i=11;i<=NF;i++){printf("%s",$i)}}' In above command i want to append some values returned by user functions on line. thnks; ajay (1 Reply)
Discussion started by: ajaypadvi
1 Replies

6. Shell Programming and Scripting

[solved] awk: placement of user-defined functions

Hi folks, is there any recommendation, especially from a point of performance, about where to place a user-defined function in awk, like in BEGIN{} or if it is only need once at the end in END{}? Or doesn't it matter at all since, awk is so clever and only interprets it once, wherever it is... (3 Replies)
Discussion started by: zaxxon
3 Replies

7. Shell Programming and Scripting

Question about awk - create a user-defined variable

Hi, guys, The content of file is below (from <UNIX® Shells by Example Fourth Edition>): My code is below: gawk -F'' ' { OFS = "****"; $3 = "(904)"; $8 = $5 + $6 + $7; print } ' lab3.data The result is below: So, where is the $1? Why is the variable $8 located at the wired position? (3 Replies)
Discussion started by: franksunnn
3 Replies

8. Shell Programming and Scripting

Doing math using user defined input and system environment variables

Hi, I need some help to setup some environmental variables. for example...Get A -> userdefined/user input B -> a number. c -> system variable...for example $GETCONF PAGE_SIZE E = do some math using bc display a message "The value is E" setup the system/kernel paramter sysctl -p... (3 Replies)
Discussion started by: saravanapandi
3 Replies

9. UNIX for Beginners Questions & Answers

How are environment variables defined in a Gnome terminal session?

Hello... and thanks in advance for any help anyone can offer me with my question! I'm hoping someone will have a little patience with me and walk me through this! I'm trying to understand a user login process on Centos 7 and I've gotten a bit confused trying to figure out when/how a Gnome... (4 Replies)
Discussion started by: bodisha
4 Replies

10. UNIX for Beginners Questions & Answers

Call user defined function from awk

My requirement is to call function ("fun1") from awk, and print its returned value along with $0. fun1() { t=$1 printf "%02d\n", $t % 60; } echo "Hi There 23" | awk '{print $0; system(fun1 $3)}' Any suggestions what to be modified in above code to achieve requirement.. (5 Replies)
Discussion started by: JSKOBS
5 Replies
platform(4)							   File Formats 						       platform(4)

NAME
platform - directory of files specifying supported platforms SYNOPSIS
.platform DESCRIPTION
The Solaris operating environment release includes the .platform directory, a new directory on the Solaris CD image. This directory con- tains files (created by Sun and Solaris OEMs) that define platform support. These files are generically referred to as platform definition files. They provide a means to map different platform types into a platform group. Platform definition files in the .platform directory are used by the installation software to ensure that software appropriate for the architecture of the system will be installed. Sun provides a platform definition file named .platform/Solaris . This file is the only one that can define platform groups to which other platform definition files can refer. For example, an OEM platform definition file can refer to any platform group specified in the Solaris platform definition file. Other platform definition files are delivered by OEMs. To avoid name conflicts, OEMs will name their platform definition file with an OEM- unique string. OEMs should use whatever string they use to make their package names unique. This unique string is often the OEM's stock symbol. Comments are allowed in a platform definition file. A "#" begins a comment and can be placed anywhere on a line. Platform definition files are composed of keyword-value pairs, and there are two kinds of stanzas in the file: platform group definitions and platform identifications. o Platform group definitions: The keywords in a platform group definition stanza are: PLATFORM_GROUP The PLATFORM_GROUP keyword must be the first keyword in the platform group definition stanza. The value assigned to this keyword is the name of the platform group, for example: PLATFORM_GROUP=sun4c The PLATFORM_GROUP name is an arbitrary name assigned to a group of platforms. However, PLATFORM_GROUP typically equals the output of the uname -m command. PLATFORM_GROUP value cannot have white space and is limited to 256 ASCII characters. INST_ARCH The instruction set architecture of all platforms in the platform group, for example: INST_ARCH=sparc The INST_ARCH keyword value must be the value returned by the uname -p command on all platforms in the platform group. o Platform identifications: The keywords in a platform identification stanza are: PLATFORM_NAME The PLATFORM_NAME keyword must be the first keyword in the platform identification stanza. The PLATFORM_NAME is the name assigned to the platform, for example: PLATFORM_NAME=SUNW,SPARCstation-5 Typically, this name is the same as the value returned by the uname -icommand on the machine, but it need not be the same. The PLATFORM_NAME value cannot have white space and is limited to 256 ASCII characters. If it contains paren- theses, it must contain only balanced parentheses. For example. the string "foo(bar)foo" is a valid value for this keyword, but "foo(bar" is not. The other keywords in the platform identification stanza can be in any order, as long as the PLATFORM_NAME keyword is first. PLATFORM_ID The value returned by the uname -i command on the machine, for example: PLATFORM_ID=SUNW,SPARCstation-5 MACHINE_TYPE The value returned by the uname -m command on the machine, for example: MACHINE_TYPE=sun4c IN_PLATFORM_GROUP The platform group of which the platform is a member, for example: IN_PLATFORM_GROUP=sun4c The platform group name must be specified in the same file as the platform identification stanza or in the platform definition file with the name .platform/Solaris . The IN_PLATFORM_GROUP keyword is optional. A platform doesn't have to belong to a platform group. If a plat- form is not explicitly assigned to a platform group, it essentially forms its own platform group, where the platform group name is the PLATFORM_NAME value. The IN_PLATFORM_GROUP value typically equals the output of the uname -m command. IN_PLATFORM_GROUP value cannot have white space and is limited to 256 ASCII characters. INST_ARCH The instruction set architecture of the platform, for example: INST_ARCH=sparc This field is only required if the platform does not belong to a platform group. The INST_ARCH keyword value must be the value returned by the uname -i command on all platforms in the platform group. COMPATIBILITY
The installation program will remain compatible with the old Solaris CD format. If a Solaris CD image does not contain any platform defini- tion files, the installation and upgrade programs will select the packages to be installed based on machine type, that is, the value returned by the uname -p command. EXAMPLES
Example 1: Platform Group Definitions The following example shows platform group definitions from the .platform/Solaris platform definition file. # PLATFORM_GROUP=sun4u INST_ARCH=sparc Example 2: Platform Identification Stanzas The following example shows platform identification stanzas, which define systems that belong in a platform group, from the .plat- form/Solaris platform definition file. # PLATFORM_NAME=SUNW,SunFire PLATFORM_ID=SUNW,SunFire IN_PLATFORM_GROUP=sun4u PLATFORM_NAME=SUNW,Ultra-80 PLATFORM_ID=SUNW,Ultra-80 IN_PLATFORM_GROUP=sun4u # PLATFORM_NAME=SUNW,SunFire PLATFORM_ID=SUNW,SunFire IN_PLATFORM_GROUP=sun4u # PLATFORM_NAME=SUNW,Ultra-80 PLATFORM_ID=SUNW,Ultra-80 IN_PLATFORM_GROUP=sun4u FILES
The .platform directory must reside as /cd_image/Solaris_vers/.platform, where cd_image Is the path to the mounted Solaris CD (/cdrom/cdrom0/s0 by default) or the path to a copy of the Solaris CD on a disk. Solaris_vers Is the version of Solaris, for example, Solaris_2.9. NOTES
Typically, a platform identification stanza contains either a PLATFORM_ID or a MACHINE_TYPE stanza, but not both. If both are specified, both must match for a platform to be identified as this platform type. Each platform identification stanza must con- tain either a PLATFORM_ID value or a MACHINE_TYPE value. If a platform matches two different platform identification stanzas--one which matched on the value of PLATFORM_ID and one which matched on the value of MACHINE_TYPE , the one that matched on PLATFORM_ID will take precedence. The .platform directory is part of the Solaris CD image, whether that be the Solaris CD or a copy of the Solaris CD on a system's hard disk. SunOS 5.10 19 Nov 2002 platform(4)
All times are GMT -4. The time now is 04:48 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy