Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
add 'sudo' to 'mv' if file isn't writable by $USER
- X-seq: zsh-users 16355
- From: TJ Luoma <luomat@xxxxxxxxx>
- To: Zsh Users <zsh-users@xxxxxxx>
- Subject: add 'sudo' to 'mv' if file isn't writable by $USER
- Date: Wed, 14 Sep 2011 18:19:26 -0400
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=mime-version:from:date:message-id:subject:to:content-type; bh=M/MUvf97qZZ+YJ0rWujUVErD3VOTVnpWlvrqO8hXj9g=; b=MFrIR6t5Cb7pEpN0T2bazmwbSuZ0aw3N9KenO5IM6NlAc+l0+Ls1G1qXuqUMDW2F3P /e7jCZ5RYEoAWzaV9TCxPGcc7ZCpXNHAini4in1XB58nxRnrkTUz+bPu3IdpeFHzXD1e A7XT5JIb9BDr54fGUuFLzhWR7aX7KCiCgFNTM=
- List-help: <mailto:zsh-users-help@zsh.org>
- List-id: Zsh Users List <zsh-users.zsh.org>
- List-post: <mailto:zsh-users@zsh.org>
- Mailing-list: contact zsh-users-help@xxxxxxx; run by ezmlm
I'm wondering if someone has already done this.
I have a function which does this:
move () {
command which -s gmv
if [ "$?" = "0" ]
then
gmv --verbose --backup=numbered $@
else
mv -v -i $@
fi
}
(simply put: use 'gmv' if it exists, otherwise use 'mv')
That works pretty well (although if there are ways to do it better,
please let me know).
HOWEVER, now I want to do
"If $FILE is writable by $USER, do 'move' as above. ELSE use 'sudo'
before the mv or gmv command"
I can probably cobble together a solution, but I thought I'd check
first to see if someone here had already invented this wheel.
TjL
Messages sorted by:
Reverse Date,
Date,
Thread,
Author