Use of && & || in Bash scripts (was: Using Ubuntu absolves the user of personal responsibility (no I'm guilty) and can you help me with my problem?)
José Paulo Matafome Oleiro
matafomeoleiro at gmail.com
Sat Aug 5 10:27:42 UTC 2006
On 8/4/06, Alexander Skwar <listen at alexander.skwar.name> wrote:
>
> · José Paulo Matafome Oleiro <matafomeoleiro at gmail.com>:
>
> > $ sudo mount -o loop -t iso9660 /isofile /mountpoint && sudo apt-get
> > install package_name && sudo mount -o loop -t
> > iso9660 /isofile /mountpoint
> > (this can mount the iso file at the end of the process again, should it
> > work, or I need to replace && with || I don't know maybe you can help me
> > with this out
>
> && means "do, if successful"
> || means "do, if not successful"
>
> Thus your command line means:
>
> mount isofile
> if that's successful, do apt-get
> if that (ie. apt-get) is successful, do mount isofile
>
> && and || are short forms for "if". Your command could also be written
> as:
>
> if sudo mount -o loop -t iso9660 /isofile /mountpoint; then
> if sudo apt-get install package_name; then
> sudo mount -o loop -t iso9660 /isofile /mountpoint
> fi
> fi
>
> Alexander Skwar
Thanks for you help
Sincerely
José Oleiro
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.ubuntu.com/archives/ubuntu-users/attachments/20060805/a3caa17a/attachment-0001.html>
More information about the ubuntu-users
mailing list