09-21-2009
echo statement when find returns null
Hi,
How do you echo something once when a find statement returns null results?
This is when using mutiple locations and mutiple arguments.
The below find command the inner loop of a nested for loop where the outter loop holds the $args and the inner loop holds the locations.
find $location -name $args
Want the statement to print 'no such file' for the $args when all locations have been searched and not found a matching file in any of the locations. But just print the location and nothing else if the arg is found in any of the locations.
Sorry if this has been asked before I've searched and not found anything.
10 More Discussions You Might Find Interesting
1. Shell Programming and Scripting
Does anyone know the correct syntax for computing arithmetic expressions inside the echo statement? Let me know, thanks (3 Replies)
Discussion started by: circleW
3 Replies
2. Shell Programming and Scripting
Okay i've got some code which reads a text file and loops through it and there a few if statements inside where one is failing (the one bolded).
Basically the acc column contains a list of three digit access codes, some though have null records (i.e nothing in the field) so what I want to do is... (3 Replies)
Discussion started by: TonyR
3 Replies
3. Shell Programming and Scripting
In my ksh script, if the conditions of a if statement are true, then do nothing; otherwise, execute some commands.
How do I write the "do nothing" statement in the following example?
Example:
if (( "$x"="1" && "$y"="a" && "$z"="happy" ))
then
do nothing
else
command
command
fi... (3 Replies)
Discussion started by: april
3 Replies
4. IP Networking
We have a code to find the DNS entry of a host that has a trailing '-' in its url (format example: mysite-.watch.com):
if(gethostbyname_r(host,host_ent,host_buffer,host_buffer_size,&host_error)==NULL)
{
//failed
}
But when remove the '-' from the host name the code does not return... (12 Replies)
Discussion started by: uunniixx
12 Replies
5. Programming
Hi all,
I am trying to write a program in C which will generate private and public keys using openssl RSA and use these for encryption and decryption. I am able to generate the keys successfully and write these to files. I am able to read the private key successfully. I can encrypt and decrypt... (1 Reply)
Discussion started by: Treasa
1 Replies
6. Shell Programming and Scripting
hi
i try to check if awk returns null
and i dont know how it's works
this is the command
set EndByC = `ls -l $base | awk '/.c$/ {print $9}'`
if ($EndByC=="") then #check if ther is XXX.c directory
echo Sorry ther is no XXX.c folder "in" $base path
echo the XXX.c folder is necessary... (6 Replies)
Discussion started by: frenkelor
6 Replies
7. Shell Programming and Scripting
I have been experiencing this problem intermittantly, I thought the problem was '/bin/sh -> /bin/dash' but I changed that to bash and the problem persists.
I am writing functions to be included in user's '.bash_profile' through source or '.' filename a quick example of the problem is illustrated... (3 Replies)
Discussion started by: bsquared
3 Replies
8. Shell Programming and Scripting
Hi,
I want to be able to check if a variable is not equal to null. I am using KSH, and am getting this error message when i run this script:
: assignment requires lvalue
The line which is causing the problem is as follows:
if (($SFTP_DESTINATION != '' ));then
if ssh... (6 Replies)
Discussion started by: Jack_Maloney
6 Replies
9. HP-UX
Hi there,
I have 2 HP-UX on same subnet and having a problem on one about ping. I'll call them as hp01 hp02.
hp01 can ping hp02 (ping says %100 transmitted)
hp01 can ssh/telnet hp02
hp02 can ssh/telnet hp01
hp02 cannot ping hp02 (ping says %100 packet loss)
There I thought of ndd... (4 Replies)
Discussion started by: royalliege
4 Replies
10. UNIX for Advanced & Expert Users
Why does this not work?
echo 'find / -iname \'*katt*\' -size +500M 2>/dev/null'
How does this work? I have 5 single quotes. I though you needed an even amount of single quotes.
echo 'find / -iname \'*katt*\' -size +500M 2>/dev/null''
What is the trick to make it work with an alias? This... (4 Replies)
Discussion started by: cokedude
4 Replies
LEARN ABOUT OPENSOLARIS
hashstat
hash(1) User Commands hash(1)
NAME
hash, rehash, unhash, hashstat - evaluate the internal hash table of the contents of directories
SYNOPSIS
/usr/bin/hash [utility]
/usr/bin/hash [-r]
sh
hash [-r] [name]...
csh
rehash
unhash
hashstat
ksh
hash [name]...
hash [-r]
DESCRIPTION
/usr/bin/hash
The /usr/bin/hash utility affects the way the current shell environment remembers the locations of utilities found. Depending on the argu-
ments specified, it adds utility locations to its list of remembered locations or it purges the contents of the list. When no arguments are
specified, it reports on the contents of the list. The -r option causes the shell to forget all remembered locations.
Utilities provided as built-ins to the shell are not reported by hash.
sh
For each name, the location in the search path of the command specified by name is determined and remembered by the shell. The -r option to
the hash built-in causes the shell to forget all remembered locations. If no arguments are given, hash provides information about remem-
bered commands. The Hits column of output is the number of times a command has been invoked by the shell process. The Cost column of output
is a measure of the work required to locate a command in the search path. If a command is found in a "relative" directory in the search
path, after changing to that directory, the stored location of that command is recalculated. Commands for which this will be done are indi-
cated by an asterisk (*) adjacent to the Hits information. Cost will be incremented when the recalculation is done.
csh
rehash recomputes the internal hash table of the contents of directories listed in the path environmental variable to account for new com-
mands added.
unhash disables the internal hash table.
hashstat prints a statistics line indicating how effective the internal hash table has been at locating commands (and avoiding execs). An
exec is attempted for each component of the path where the hash function indicates a possible hit and in each component that does not begin
with a '/'.
ksh
For each name, the location in the search path of the command specified by name is determined and remembered by the shell. The -r option to
the hash built-in causes the shell to forget all remembered locations. If no arguments are given, hash provides information about remem-
bered commands.
OPERANDS
The following operand is supported by hash:
utility The name of a utility to be searched for and added to the list of remembered locations.
OUTPUT
The standard output of hash is used when no arguments are specified. Its format is unspecified, but includes the pathname of each utility
in the list of remembered locations for the current shell environment. This list consists of those utilities named in previous hash invoca-
tions that have been invoked, and may contain those invoked and found through the normal command search process.
ENVIRONMENT VARIABLES
See environ(5) for descriptions of the following environment variables that affect the execution of hash: LANG, LC_ALL, LC_CTYPE, LC_MES-
SAGES, and NLSPATH.
PATH Determine the location of utility.
EXIT STATUS
The following exit values are returned by hash:
0 Successful completion.
>0 An error occurred.
ATTRIBUTES
See attributes(5) for descriptions of the following attributes:
+-----------------------------+-----------------------------+
| ATTRIBUTE TYPE | ATTRIBUTE VALUE |
+-----------------------------+-----------------------------+
|Availability |SUNWcsu |
+-----------------------------+-----------------------------+
|Interface Stability |Standard |
+-----------------------------+-----------------------------+
SEE ALSO
csh(1), ksh(1), sh(1), attributes(5), environ(5), standards(5)
SunOS 5.11 17 Jul 2002 hash(1)