public inbox for gentoo-user@lists.gentoo.org
 help / color / mirror / Atom feed
From: Alexander Skwar <listen@alexander.skwar.name>
To: gentoo-user@lists.gentoo.org
Subject: Re: [gentoo-user] [OT] Bash scripting 2
Date: Fri, 11 Nov 2005 21:47:35 +0100	[thread overview]
Message-ID: <43750367.8070509@mid.email-server.info> (raw)
In-Reply-To: <200511111857.40664.peper@aster.pl>

Peper schrieb:
> Hello,
> How can i check whether i can create or overwrite a file?

You need write access on the directory for creating files and
on the file for overwriting.

> For example:
> If /etc/conf.d/net cannot be overwritten or created it return false.

Use "test" or "[" or "[[".

> Overwriting test would be -w /etc/conf.d/net,

Yep.

> but how can i check if i can 
> create this file?

[[ -w `dirname /etc/conf.d/net` ]] && echo can create file

> I could check whether i can create new files 
> in /etc/conf.d,

Yep.

> but how can i get /etc/conf.d/ from /etc/conf.d/net ?

dirname. Or if you've got that in an environment variable,
you use "Parameter Expansion".

file=/etc/conf.d/net
echo ${file%/*}

Alexander Skwar
-- 
gentoo-user@gentoo.org mailing list



  parent reply	other threads:[~2005-11-11 20:54 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-11-11 17:57 [gentoo-user] [OT] Bash scripting 2 Peper
2005-11-11 18:23 ` Peter De Zutter
2005-11-11 18:25 ` Renat Golubchyk
2005-11-11 18:33   ` [gentoo-user] " Peper
2005-11-11 20:47 ` Alexander Skwar [this message]
2005-11-12  0:48   ` Peper

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=43750367.8070509@mid.email-server.info \
    --to=listen@alexander.skwar.name \
    --cc=gentoo-user@lists.gentoo.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox