How to pass nawk variable to shell within the same script?
Hi All,
I tried googling but so far no luck, can someone tell me how pass the variable value used inside the
nawk command to shell. In the below script i get the value of $c (without color: Total Executed: " c ")
but the printf which is outside the nawk command doesn't print the value or it always prints $c as null.
Hi,
I am calling an oracle function that returns a number (either 0 or 2), how do I pass that pass to the wrapping shell script as I would like to do other things based on the value returned by the oracle function.
Your help will be appreciated.
--------------------------
sqlplus / <<... (3 Replies)
Hi ,
i am beginner to Unix, I have one small script which execute java programme,it has java command input output structure . Right now i have given Input output structure manually that is on same directory, now how can i pass that by commandline
#!/bin/sh
java Classjava input.txt... (5 Replies)
Dear friends,
please tell me how to pass the external variable values to the nawk command.
length=`expr $len2 - $len1`
i need to pass $length to following nawk command as mentioned below.
nawk '{if((x=index($0,"W/X"))>0){id=substr($0,x, $length);print x;print id;}}' filename1
but I am... (1 Reply)
Hi,
I have a shell script with an ambedded awk script.
i need to pass a script variable to the awk script.
Please help.
Thanks in advance
Himani (3 Replies)
Hello experts,
can I return a value from gawk to a shell script ?
My script as follows,
#Here I want the num value to shell script so that I can use later
gawk '
{
split($0,num,",");
print num
}'
gawk -v no=$number '{print no}'
file1
... (3 Replies)
Hello Experts,
Actually I was searching for a solution here in this forum , but didn't get what exactly I want . Is this possible to do in awk ?
I am trying to do some thing like below in ksh script . Upto my knowledge I can pass shell script to awk with "-v " option.
But I... (3 Replies)
I need to parse log files using nawk, but I'm not able to pass script input argument (date) to nawk, for example:
------------
#!/bin/ksh
read date
nawk -F, '{if($1==date) print $4" "$5}'
-------------
Is there a way to pass an argument to nawk from shell script.
Many thanks... (8 Replies)
I have a shell script (.sh) and I want to pass a parameter value to the awk command but I am getting exception, please assist.
diff=$1$2.diff
id=$2 new=new_$diff
echo "My id is $1"
echo "I want to sync for user account $id"
##awk command I am using is as below
cat $diff | awk... (2 Replies)
Hi,
I am in critical need of help, Thanks a ton for your help.
I need to know how to pass the shell argument into nawk code in AIX. so that my file gets passed into that awk script and it can execute it part.
To be detail, i have more than 100 files and in those files a particular field... (6 Replies)
Hi,
Please need to print the Rej variable outsite the awk script which is given below...please advised how to achieve it.
#!/bin/bash
echo "Enter DMU Pipe delimited File name for the Feed to be validated"
read DMU_File
echo "Enter Pre-DMU File name for the Feed"
read Predum_file
... (3 Replies)
Discussion started by: pelethangjam
3 Replies
LEARN ABOUT DEBIAN
filesys::df
Df(3pm) User Contributed Perl Documentation Df(3pm)NAME
Filesys::Df - Perl extension for filesystem disk space information.
SYNOPSIS
use Filesys::Df;
#### Get information by passing a scalar directory/filename value
my $ref = df("/tmp"); # Default output is 1K blocks
if(defined($ref)) {
print "Total 1k blocks: $ref->{blocks}
";
print "Total 1k blocks free: $ref->{bfree}
";
print "Total 1k blocks avail to me: $ref->{bavail}
";
print "Total 1k blocks used: $ref->{used}
";
print "Percent full: $ref->{per}
";
if(exists($ref->{files})) {
print "Total inodes: $ref->{files}
";
print "Total inodes free: $ref->{ffree}
";
print "Inode percent full: $ref->{fper}
";
}
}
#### Get information by passing a filehandle
open(FILE, "some_file"); # Get information for filesystem at "some_file"
my $ref = df(*FILE);
#### or
my $ref = df(*FILE);
#### or
my $fhref = *FILE;
my $ref = df($fhref);
#### Get information in other than 1k blocks
my $ref = df("/tmp", 8192); # output is 8K blocks
my $ref = df("/tmp", 1); # output is bytes
DESCRIPTION
This module provides a way to obtain filesystem disk space information. This is a Unix only distribution. If you want to gather this
information for Unix and Windows, use "Filesys::DfPortable". The only major benefit of using "Filesys::Df" over "Filesys::DfPortable", is
that "Filesys::Df" supports the use of open filehandles as arguments.
The module should work with all flavors of Unix that implement the "statvfs()" and "fstatvfs()" calls, or the "statfs()" and "fstatfs()"
calls. This would include Linux, *BSD, HP-UX, AIX, Solaris, Mac OS X, Irix, Cygwin, etc ...
"df()" requires a argument that represents the filesystem you want to query. The argument can be either a scalar directory/file name or a
open filehandle. There is also an optional block size argument so you can tailor the size of the values returned. The default block size is
1024. This will cause the function to return the values in 1k blocks. If you want bytes, set the block size to 1.
"df()" returns a reference to a hash. The keys available in the hash are as follows:
"{blocks}" = Total blocks on the filesystem.
"{bfree}" = Total blocks free on the filesystem.
"{bavail}" = Total blocks available to the user executing the Perl application. This can be different than "{bfree}" if you have per-user
quotas on the filesystem, or if the super user has a reserved amount. "{bavail}" can also be a negative value because of this. For
instance if there is more space being used then you have available to you.
"{used}" = Total blocks used on the filesystem.
"{per}" = Percent of disk space used. This is based on the disk space available to the user executing the application. In other words, if
the filesystem has 10% of its space reserved for the superuser, then the percent used can go up to 110%.
You can obtain inode information through the module as well, but you must call "exists()" on the "{files}" key first, to make sure the
information is available. Some filesystems may not return inode information, for example some NFS filesystems.
Here are the available inode keys:
"{files}" = Total inodes on the filesystem.
"{ffree}" = Total inodes free on the filesystem.
"{favail}" = Total inodes available to the user executing the application. See the rules for the "{bavail}" key.
"{fused}" = Total inodes used on the filesystem.
"{fper}" = Percent of inodes used on the filesystem. See rules for the "{per}" key.
There are some undocumented keys that are defined to maintain backwards compatibilty: "{su_blocks}", "{user_blocks}", etc ...
If the "df()" call fails for any reason, it will return undef. This will probably happen if you do anything crazy like try to get
information for /proc, or if you pass an invalid filesystem name, or if there is an internal error. "df()" will "croak()" if you pass it a
undefined value.
Requirements: Your system must contain "statvfs()" and "fstatvfs()", or "statfs()" and "fstatfs()" You must be running Perl 5.6 or higher.
AUTHOR
Ian Guthrie IGuthrie@aol.com
Copyright (c) 2006 Ian Guthrie. All rights reserved.
This program is free software; you can redistribute it and/or
modify it under the same terms as Perl itself.
SEE ALSO statvfs(2), fstatvfs(2), statfs(2), fstatfs(2), df(1), Filesys::DfPortable
perl(1).
perl v5.14.2 2006-06-25 Df(3pm)