Sponsored Content
Top Forums Shell Programming and Scripting How to store the return value of a command into a variable? Post 302569518 by CarloM on Monday 31st of October 2011 02:26:45 PM
Old 10-31-2011
iirc, $(...) is the POSIX version, and backquoting functionality isn't required by the standard. Although I could be wrong...
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

How to Store command O/P to a variable...

Hi all.. I got a problem.. Its easy to redirect o/p to a file.. But Is it possible to redirect the O/P to a variable? For example: I've a command in my script: string1=cut -d ':' -f2 file.txt When I do: echo $string1 The value is empty... Pls suggest me how to store the value... (7 Replies)
Discussion started by: smartbuddy
7 Replies

2. Shell Programming and Scripting

how to store grep command in a Variable

I have a variable A echo $A 5060 I am exporting the value X,Y,Z and it id fetching right thing and When I run C=`${X} -l ${Y} ${Z} "trap '' INT;. ~/.profile >/dev/null 2>/dev/null; netstat -na | grep \$A`" here it is going to same directory and also running netstat -na | grep 5060 ... (4 Replies)
Discussion started by: madhusmita
4 Replies

3. Shell Programming and Scripting

Insert a line including Variable & Carriage Return / sed command as Variable

I want to instert Category:XXXXX into the 2. line something like this should work, but I have somewhere the wrong sytanx. something with the linebreak goes wrong: sed "2i\\${n}Category:$cat\n" Sample: Titel Blahh Blahh abllk sdhsd sjdhf Blahh Blah Blahh Blahh Should look like... (2 Replies)
Discussion started by: lowmaster
2 Replies

4. Shell Programming and Scripting

Store highest filename from ls command to a variable

I am sure it has been answered in some form or the other in this forum but trust me I have spent last couple of hours looking for an answer but can't find it. I want to do a very simple operation within my script. Let's say I have 4 files with the names file1.log, file2.log, file3.log and... (6 Replies)
Discussion started by: sssccc
6 Replies

5. Shell Programming and Scripting

Not able to store command inside a shell variable, and run the variable

Hi, I am trying to do the following thing var='date' $var Above command substitutes date for and in turn runs the date command and i am getting the todays date value. I am trying to do the same thing as following, but facing some problems, unique_host_pro="sed -e ' /#/d'... (3 Replies)
Discussion started by: gvinayagam
3 Replies

6. Shell Programming and Scripting

Using variable to store of find command

Hello Experts I am newbie to unix and writing one script to make archive files Problme i am facing is : I have used find command to find the type of files and I am storing find command results in a variable. When I echo the variable I can see that path is printed properly but when i am... (5 Replies)
Discussion started by: mitsyjohn
5 Replies

7. Shell Programming and Scripting

To store the file name o/p from find command in to a variable

Hi How to use a variable to store the filename of a file which was found by the 'find' command. can this be practical-->var = find . -name "filename.dat" Please help.. (1 Reply)
Discussion started by: ayyappaas
1 Replies

8. Shell Programming and Scripting

variable value return of multiple command

I wrote this script #!/bin/bash var=`du -sch /var/log/messages;du -sch /var/log/maillog` echo $var I am getting result as follows. # sh my.sh 2.1M /var/log/messages 2.1M total 296K /var/log/maillog 296K total I need it like below 2.1M /var/log/messages 296K... (3 Replies)
Discussion started by: anilcliff
3 Replies

9. Shell Programming and Scripting

Store command inside variable

Is it possible to store a command inside a variable? i want this piece to be stored inside a variable, so i can use it later in a different command $u | cut -d " " -f 2 var="$u | cut -d " " -f 2" eval $var I tried to use eval but I receive this error: -f 2: command not found ... (5 Replies)
Discussion started by: velos
5 Replies

10. Programming

Python - store output of command to a variable

I am trying to store output of python command in variable. Could you please help how I can do that ? For example I am executing the following command - "CentOS" in server_desc The output would be True or False I would like to store the output in a variable say outPut and use condition... (4 Replies)
Discussion started by: atanubanerji
4 Replies
stdsyms(5)							File Formats Manual							stdsyms(5)

NAME
stdsyms - description of named defines and other specifications for namespace from HP-UX header files DESCRIPTION
is a description of "named defines" and other specifications that must be set by the application to obtain the appropriate namespace from the HP-UX header files. HP-UX header files are organized in a manner that allows for only a subset of the symbols available in that header file to be visible to an application that conforms to a specific standard. The ANSI-C, POSIX.1, POSIX.2, XPG4 and subsequent enhanced versions of ANSI-C/POSIX/XPG each reserve a certain set of symbols for that standard's namespace. In addition, the HP-UX implementation of XPG3 and the "OSF AES/OS" provides for a clean namespace although this is not a specific requirement of those standards. The following rules apply in determining what symbols are reserved for any standard. These symbols are reserved for the standard and for use by the implementation, and must be either avoided altogether, or used exactly as defined by the specified standard. o All symbols defined by the desired standard are reserved. Refer to the appropriate standards documentation for a complete list of reserved symbols. o All symbols beginning with an underscore followed by another underscore or an uppercase letter are reserved for the implementation. o All external identifiers beginning with an underscore are reserved for the implementation. The following is a list of feature test macros which must be defined to obtain the appropriate namespace from the header files. This symbol is automatically defined by the ANSI-C preprocessor and is automatically defined when specifying an ANSI-C compile Using the strict ANSI option requests a pure ANSI-C namespace, which is the smallest subset of the HP-UX namespace available. The option also enables the inclusion of ANSI-C-style function prototypes for increased type checking. Note that the default namespace when using the option is the ANSI-C namespace; therefore a broader namespace must be requested if it is desired. This symbol is automatically defined by the ANSI-C preprocessor on some implementations. If defined, it indicates the version of the standard it is complying with. As documented in the IEEE POSIX.1 standard, the programmer is required to define the feature test macro to obtain the POSIX.1 namespace and POSIX.1 functionality. This feature test macro can be defined, either by using compiler options or by using directives in the source files before any directives. Note that the default POSIX namespace is the POSIX.1-1990 namespace. It is necessary to define the feature test macro in addition to the macro in order to obtain the POSIX.1-1988 namespace. As documented in the IEEE POSIX.2 standard, the programmer is required to define the feature test macro with a value of 2 to obtain the POSIX.1 and POSIX.2 namespaces and functionality. This feature test macro can be defined, either by using compiler options or by using directives in the source files before any directives. As documented in the X/Open Portability Guide the programmer is required to define the feature test macro to obtain X/Open functionality. This feature test macro can be defined, either by using compiler options or by using directives in the source files before any directives. Although XPG3 does not specify any namespace pollution rules, XPG4 and its subsequent versions have instituted such rules. Therefore, the HP-UX operating system provides clean namespaces whenever is defined. The current default X/Open namespace is that corresponding to XPG4. Broader namespace can be requested by setting to a value as specified by the standard document. As documented in the XPG, the programmer is required to define the feature test macro to obtain namespace and functionality. This feature test macro can be defined either by using com- piler option or by using directives in the source files before any directives. As documented in the "OSF AES/OS" standard, the programmer is required to define the feature test macro to obtain OSF functionality. This feature test macro can be defined, either by using compiler options or by using directives in the source files before any directives. Although the AES does not specify any namespace pollution rules, the other standards have instituted such rules. Therefore HP-UX provides a clean names- pace whenever is defined. Use of is strongly discouraged as this functionality will be removed in a future release of HP-UX. The programmer can define the feature test macro to obtain the HP-UX namespace and complete HP-UX functionality. Note that the HP-UX namespace is currently a superset of all of the above mentioned namespaces. When using the compiler with default options or the compiler with compatibility- mode options command without the option), the HP-UX namespace is provided by default (see cc(1)). The programmer must request one of the other namespaces as described above to obtain the appropriate subset of the HP-UX namespace. When using the strict ANSI-C- mode compiler the programmer must specifically request a broader namespace. The feature test macro can be defined, either by using compiler options or by using directives in the source files before any direc- tives. The following is a list of miscellaneous feature test macros that provide various additional features. This symbol is automatically defined by the HP C++ compiler. Defining this macro enables the C++ function prototypes in system header files. The default namespace for HP C++ is the ANSI-C namespace. To obtain another namespace define the appropriate feature test macro. HP C++ uses the ANSI-C preprocessor by default. To get the compatibility mode preprocessor, use the option of the command (see cc(1)). The compatibility mode preprocessor uses the HP-UX namespace This feature test macro should be defined when the namespace is required. It should be used in conjunction with the macro if the default namespace is not desired. This macro is defined automatically whenever or is requested. The feature test macro is provided so that the programmer can obtain the XPG3 namespace, since it differs slightly from the namespace. In order to obtain the XPG3 namespace, the programmer must define both the and feature test macros. The and feature test macros can be defined, either by using compiler options or by using directives in the source files before any directives. Use of this macro is strongly discouraged as this functionality will be removed in a future release of HP-UX. The feature test macro is defined automatically if the programmer has requested the XPG4 namespace (that is, defined but not some other conflicting namespace such as The macro can be defined when using the compatibility mode compiler to obtain SVID2 function return types in the HP-UX namespace. The default return types of many functions have since been changed in the HP-UX operating system to align with the ANSI-C, POSIX, X/Open, and OSF standards. Use of this macro is strongly discouraged as this functionality will be removed in a future release of HP-UX. The SVID3 macro can be defined to obtain SVID3 function prototypes. The compiler flag, needs to be defined to indicate that an application is written to meet SVID3 requirements. At the time the func- tion prototypes were introduced in ANSI C, the functions exposed by this flag were only defined in SVID3. SEE ALSO
cc(1), cpp(1), pathconf(2), sysconf(2), standards(5). stdsyms(5)
All times are GMT -4. The time now is 05:10 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy