* help with a bash script please
@ Gregory Nowak
` Raul A. Gallegos
` (3 more replies)
0 siblings, 4 replies; 5+ messages in thread
From: Gregory Nowak @ UTC (permalink / raw)
To: speakup
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Hi all.
I'm having trouble with an if statement in a bash script I'm
writing. What I want to do, is to check if a file doesn't have read
permission. What I'm doing is:
if !([ -r filename])
However, bash says that the command [-r is not found on line
number. Can someone please tell me what I'm doing wrong, and show me
how to do what I want to do properly? Thanks in advance.
Greg
- --
web site: http://www.romuald.net.eu.org
gpg public key: http://www.romuald.net.eu.org/pubkey.asc
skype: gregn1
(authorization required, add me to your contacts list first)
- --
Free domains: http://www.eu.org/ or mail dns-manager@EU.org
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.2.2 (GNU/Linux)
iD8DBQFEODZY7s9z/XlyUyARAgVJAKCyow1QR5lo7DjsNxUfAavCO86gFQCgmC+i
S58rlWJzeICulyaj9sKfono=
=QG4s
-----END PGP SIGNATURE-----
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: help with a bash script please
help with a bash script please Gregory Nowak
@ ` Raul A. Gallegos
` Garrett Klein
` (2 subsequent siblings)
3 siblings, 0 replies; 5+ messages in thread
From: Raul A. Gallegos @ UTC (permalink / raw)
To: speakup
Gregory Nowak said the following on Sat, Apr 08, 2006 at 03:16:56PM -0700:
> I'm having trouble with an if statement in a bash script I'm
> writing. What I want to do, is to check if a file doesn't have read
> permission. What I'm doing is:
>
> if !([ -r filename])
Try this:
if [ ! -r filename ]; then
That should work. I tried this on a file called test with chmod 000
then chmod 666 and on 000 the script was true due to the exclamation
but false when the file was chmod 666 since the script then made it
false.
The quick script I wrote is as follows:
#!/bin/bash
if [ ! -r test ]; then
echo "this file is not readable"
else
echo "this file is readable"
fi
HTH.
--
All I want is a warm bed and a kind word and unlimited power.
-- Ashleigh Brilliant
Raul A. Gallegos ... IliwSsmc
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: help with a bash script please
help with a bash script please Gregory Nowak
` Raul A. Gallegos
@ ` Garrett Klein
` Lorenzo Taylor
` Tyler Littlefield
3 siblings, 0 replies; 5+ messages in thread
From: Garrett Klein @ UTC (permalink / raw)
To: Speakup is a screen review system for Linux.
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Greg,
What you're looking for is
if [ !-r filename ]; then
#commands here;
fi
HTH,
Garrett
On Sat, Apr 08, 2006 at 03:16:56PM -0700, Gregory Nowak wrote:
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> Hi all.
>
> I'm having trouble with an if statement in a bash script I'm
> writing. What I want to do, is to check if a file doesn't have read
> permission. What I'm doing is:
>
> if !([ -r filename])
>
> However, bash says that the command [-r is not found on line
> number. Can someone please tell me what I'm doing wrong, and show me
> how to do what I want to do properly? Thanks in advance.
>
> Greg
>
>
> - --
> web site: http://www.romuald.net.eu.org
> gpg public key: http://www.romuald.net.eu.org/pubkey.asc
> skype: gregn1
> (authorization required, add me to your contacts list first)
>
> - --
> Free domains: http://www.eu.org/ or mail dns-manager@EU.org
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG v1.4.2.2 (GNU/Linux)
>
> iD8DBQFEODZY7s9z/XlyUyARAgVJAKCyow1QR5lo7DjsNxUfAavCO86gFQCgmC+i
> S58rlWJzeICulyaj9sKfono=
> =QG4s
> -----END PGP SIGNATURE-----
>
> _______________________________________________
> Speakup mailing list
> Speakup@braille.uwo.ca
> http://speech.braille.uwo.ca/mailman/listinfo/speakup
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.2.2 (GNU/Linux)
iQIVAwUBRDg7rfQ3GgYHRr/HAQKv4A/+N0D2A7fSOgT0naxv05LQpWTfLLJAM8RE
rORVunmgcrY+uKCnP0KIOBYGQz4PgHtqd5TMqO8NNIUBvvHQkOMMEmU0FpTuYhTI
4XuTjQZGSKbD4DhCNoIadi+56+9rjdWhsdiI4wtlrpYgWLoKdHRmuqEPgcS3yy8S
BnlcXWbKHFH+/iypxd4li17dFem3XHKoB3nlIqMl6nIqLIFlJXPSjMlIXJpgfLXF
PN4vhTy3+dVClxz5ShPAAIwxHZjcNLb8h3usCnKQS0dNY3+Zxrv1TM/3f5pTHsm1
xFKWe89U+1HUrzox86ivIDfiUl2/UDxroYKksPYbPfIt2qFDJRUu5TS9+vOYHvsn
GpCQ8xC8/DJLP24MWH+0P0uHSkFt/rtm38sLIDm4DIEJrm73KLvkQCG6anps41FS
boOt4g/5nsKhy2HV0VFI7ZwpZinTzDk2+eH3X82PQs7EsZXoHzdOyS/q+yKXQZlZ
xZ+Z7AW8PasmDNa4q+K/ZpNI0Nf9KsmFZ6ltUUr2jt967zmb5EFMMhXv62ot5TBe
RY/yGFm6VCU18VRfwqIglc6/3tFpMVh/WNMLevJL5AX7UN6dn6r94NDKgnzs8EUI
nCnB7eU6u7EeC0ocvHjCtCvwRsLwDwPvo0RR1lMTXG6Q4f5+WtD/qy0BATYNerhw
UiSE/mEnEj8=
=0Vdh
-----END PGP SIGNATURE-----
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: help with a bash script please
help with a bash script please Gregory Nowak
` Raul A. Gallegos
` Garrett Klein
@ ` Lorenzo Taylor
` Tyler Littlefield
3 siblings, 0 replies; 5+ messages in thread
From: Lorenzo Taylor @ UTC (permalink / raw)
To: Speakup is a screen review system for Linux.
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Remove the parentheses and move the ! into the brackets.
if [ ! -r filename ]
HTH,
Lorenzo
- --
Q: What do you call a blind, deaf-mute, quadraplegic Virginian?
A: Trustworthy.
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.3 (GNU/Linux)
iD8DBQFEODxeG9IpekrhBfIRAmaCAKDH9/RLjBoJoX+MKz+Sd3jLQcREPQCeJbXe
Z+FDmehsyPyMJEYbesK5/w0=
=MqcP
-----END PGP SIGNATURE-----
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: help with a bash script please
help with a bash script please Gregory Nowak
` (2 preceding siblings ...)
` Lorenzo Taylor
@ ` Tyler Littlefield
3 siblings, 0 replies; 5+ messages in thread
From: Tyler Littlefield @ UTC (permalink / raw)
To: Speakup is a screen review system for Linux.
I am not the best, and haven't looked at bash, but try moving the ! to the
inside of the parens.
Thanks,
----- Original Message -----
From: "Gregory Nowak" <greg@romuald.net.eu.org>
To: <speakup@braille.uwo.ca>
Sent: Saturday, April 08, 2006 4:16 PM
Subject: help with a bash script please
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> Hi all.
>
> I'm having trouble with an if statement in a bash script I'm
> writing. What I want to do, is to check if a file doesn't have read
> permission. What I'm doing is:
>
> if !([ -r filename])
>
> However, bash says that the command [-r is not found on line
> number. Can someone please tell me what I'm doing wrong, and show me
> how to do what I want to do properly? Thanks in advance.
>
> Greg
>
>
> - --
> web site: http://www.romuald.net.eu.org
> gpg public key: http://www.romuald.net.eu.org/pubkey.asc
> skype: gregn1
> (authorization required, add me to your contacts list first)
>
> - --
> Free domains: http://www.eu.org/ or mail dns-manager@EU.org
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG v1.4.2.2 (GNU/Linux)
>
> iD8DBQFEODZY7s9z/XlyUyARAgVJAKCyow1QR5lo7DjsNxUfAavCO86gFQCgmC+i
> S58rlWJzeICulyaj9sKfono=
> =QG4s
> -----END PGP SIGNATURE-----
>
> _______________________________________________
> Speakup mailing list
> Speakup@braille.uwo.ca
> http://speech.braille.uwo.ca/mailman/listinfo/speakup
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~ UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
help with a bash script please Gregory Nowak
` Raul A. Gallegos
` Garrett Klein
` Lorenzo Taylor
` Tyler Littlefield
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).