Sponsored Content
Top Forums Shell Programming and Scripting How to use same variable value inside as well as outside of the awk command? Post 302459022 by fpmurphy on Sunday 3rd of October 2010 10:03:17 AM
Old 10-03-2010
Please provide an example of the data that is in the $DATA_DIR/count.txt data file.

Why the need to invoke awk twice? Print the number of records at the top of the output?

Why do you need so many print statements? Why not just output the lines which are regarded as "errors"? Each print statement adds to the execution time.
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

variable inside awk '{print $c}'

i'm trying to do this (in bash darwin); echo "give me some words: " read a c=2 # this is get by other ways echo $a | awk '{print $c}' # i want to print the column given # by de $c variable if there is someone understand what i pretend... (3 Replies)
Discussion started by: Tártaro
3 Replies

2. Shell Programming and Scripting

getting variable inside awk

Hi All, I have awk script for replacing the nth ocurance of a string in an xml file... My code is like this FILETYPE=xml TAGNAME=type OCCURANCE=$1 TAGVALUE=valueur echo OCCURANCE:$OCCURANCE echo TAGNAME:$TAGNAME echo TAGVALUE:$TAGVALUE awk -v n=$OCCURANCE -v... (1 Reply)
Discussion started by: subin_bala
1 Replies

3. Shell Programming and Scripting

Using variable inside awk

I am trying to print the lines with pattern and my pattern is set to a variable express awk '/$express/{where=NR;print}' test2.log I am not getting any data even though i have the data with the pattern. Can seomeone correct me with the awk command above? (20 Replies)
Discussion started by: rdhanek
20 Replies

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

5. Shell Programming and Scripting

Using variable inside awk

Hi, Please help me how to use variables inside awk in code below: ll | awk -v "yr=`date '+%Y'`" -v "mnth=`date '+%m'`" -v Jan=1 -v Feb=2 -v Mar=3 -v Apr=4 -v May=5 -v Jun=6 -v Jul=7 -v Aug=8 ' !/^d/ { if(NR>1) {printf "%-29s\t\t%s\t%5s\t\t%s %s,", $9,$1,$5,$`$6`,$7} }' Thanks. (10 Replies)
Discussion started by: manubatham20
10 Replies

6. Shell Programming and Scripting

Problem using variable inside awk

HI, This is the code I am using: awk -v aaa="connect" 'BEGIN {IGNORECASE} /aaa/,/!/ {print NR}' bb This does not throw any error but it does not work. Pls help Thanks. (4 Replies)
Discussion started by: sudvishw
4 Replies

7. Shell Programming and Scripting

HELP with AWK one-liner. Need to employ an If condition inside AWK to check for array variable ?

Hello experts, I'm stuck with this script for three days now. Here's what i need. I need to split a large delimited (,) file into 2 files based on the value present in the last field. Samp: Something.csv bca,adc,asdf,123,12C bca,adc,asdf,123,13C def,adc,asdf,123,12A I need this split... (6 Replies)
Discussion started by: shell_boy23
6 Replies

8. Shell Programming and Scripting

Passing awk variable argument to a script which is being called inside awk

consider the script below sh /opt/hqe/hqapi1-client-5.0.0/bin/hqapi.sh alert list --host=localhost --port=7443 --user=hqadmin --password=hqadmin --secure=true >/tmp/alerts.xml awk -F'' '{for(i=1;i<=NF;i++){ if($i=="Alert id") { if(id!="") if(dt!=""){ cmd="sh someScript.sh... (2 Replies)
Discussion started by: vivek d r
2 Replies

9. Shell Programming and Scripting

Variable assignment inside awk

Hi, Was hoping someone could help with the following: while read line; do pntadm -P $line | awk '{if (( $2 == 00 && $1 != 00 ) || ( $2 == 04 )) print $3,$5}'; done < /tmp/subnet_list Anyone know if it is possible to assign $3 and $5 to separate variables within the {} brackets? Thanks... (14 Replies)
Discussion started by: CiCa
14 Replies

10. UNIX for Beginners Questions & Answers

Variable and awk inside for loop

Thanks all for taking time out and reading this thread and big Thanks to all who have come forward for rescue. Background: I have a variable "nbrofcols" that has number of columns from a data file. Now, using this count in for loop, I am trying to get the maximum length of each column present... (7 Replies)
Discussion started by: svks1985
7 Replies
seinfo(1)						      General Commands Manual							 seinfo(1)

NAME
seinfo - SELinux policy query tool SYNOPSIS
seinfo [OPTIONS] [EXPRESSION] [POLICY ...] DESCRIPTION
seinfo allows the user to query the components of a SELinux policy. POLICY
seinfo supports loading a SELinux policy in one of four formats. source A single text file containing policy source for versions 12 through 21. This file is usually named policy.conf. binary A single file containing a monolithic kernel binary policy for versions 15 through 21. This file is usually named by version - for example, policy.20. modular A list of policy packages each containing a loadable policy module. The first module listed must be a base module. policy list A single text file containing all the information needed to load a policy, usually exported by SETools graphical utilities. If no policy file is provided, seinfo will search for the system default policy: checking first for a source policy, next for a binary pol- icy matching the running kernel's preferred version, and finally for the highest version that can be found. In the latter case, the policy will be downgraded to match the running system. If no policy can be found, seinfo will print an error message and exit. EXPRESSIONS
One or more of the following component types can be queried. Each option may only be specified once. If an option is provided multiple times, the last instance will be used. Some components support the -x flag to print expanded information about that component; if a partic- ular component specified does not support expanded information, the flag will be ignored for that component (see -x below). If no expres- sions are provided, policy statistics will be printed (see --stats below). -c[NAME], --class[=NAME] Print a list of object classes or, if NAME is provided, print the object class NAME. With -x, print a list of permissions for each displayed object class. --sensitivity[=NAME] Print a list of sensitivities or, if NAME is provided, print the sensitivity NAME. With -x, print the corresponding level statement for each displayed sensitivity. --category[=NAME] Print a list of categories or, if NAME is provided, print the category NAME. With -x, print a list of sensitivities with which each displayed category may be associated. -t[NAME], --type[=NAME] Print a list of types (not including aliases or attributes) or, if NAME is provided, print the type NAME. With -x, print a list of attributes which include each displayed type. -a[NAME], --attribute[=NAME] Print a list of type attributes or, if NAME is provided, print the attribute NAME. With -x, print a list of types assigned to each displayed attribute. -r[NAME], --role[=NAME] Print a list of roles or, if NAME is provided, print the role NAME. With -x, print a list of types assigned to each displayed role. -u[NAME], --user[=NAME] Print a list of users or, if NAME is provided, print the user NAME. With -x, print a list of roles assigned to each displayed user. -b[NAME], --bool[=NAME] Print a list of conditional booleans or, if NAME is provided, print the boolean NAME. With -x, print the default state of each dis- played conditional boolean. --initialsid[=NAME] Print a list of initial SIDs or, if NAME is provided, print the initial SID NAME. With -x, print the context assigned to each dis- played SID. --fs_use[=TYPE] Print a list of fs_use statements or, if TYPE is provided, print the statement for filesystem TYPE. There is no expanded informa- tion for this component. --genfscon[=TYPE] Print a list of genfscon statements or, if TYPE is provided, print the statement for the filesystem TYPE. There is no expanded information for this component. --netifcon[=NAME] Print a list of netif contexts or, if NAME is provided, print the statement for interface NAME. There is no expanded information for this component. --nodecon[=ADDR] Print a list of node contexts or, if ADDR is provided, print the statement for the node with address ADDR. There is no expanded information for this component. --portcon[=PORT] Print a list of port contexts or, if PORT is provided, print the statement for port PORT. There is no expanded information for this component. --protocol=PROTO Print only portcon statements for the protocol PROTO. This option is ignored if portcon statements are not printed or if no state- ment exists for the requested port. --constrain Print a list of constraints. There is no expanded information for this component. --all Print all components. OPTIONS
-x, --expand Print additional details for each component matching the expression. These details include the types assigned to an attribute or role and the permissions for an object class. This option is not available for all component types; see the description of each component for the details this option will provide. --stats Print policy statistics including policy type and version information and counts of all components and rules. -l Print line breaks when displaying constraint statements. -h, --help Print help information and exit. -V, --version Print version information and exit. AUTHOR
This manual page was written by Jeremy A. Mowery <jmowery@tresys.com>. COPYRIGHT
Copyright(C) 2003-2010 Tresys Technology, LLC BUGS
Please report bugs via an email to setools-bugs@tresys.com. SEE ALSO
sesearch(1), apol(1) seinfo(1)
All times are GMT -4. The time now is 06:17 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy