Sponsored Content
Operating Systems OS X (Apple) bash script for dseditgroups in OSX Post 302488860 by [MA]Flying_Meat on Tuesday 18th of January 2011 03:16:15 PM
Old 01-18-2011
Quote:
Originally Posted by stop.the.stupid
if [[ $a != "Shared" ]]; then
# Excludes the dog directory
if [[ $a != "dog" ]]; then
# Excludes the DOG directory
if [[ $a != "DOG" ]]; then
Just a tip on nested if statements:
Code:
if [ $a != "Shared" ] || [ $a != "dog" ] || [ $a != "DOG" ]; then

Should do the same thing (process anything other than Shared, dog or DOG), and is a little easier to look at. "||" equals "or".
There are other ways to pare down these types of statements, but I have used this construct successfully in a few scripts in the past...

Last edited by Scott; 01-18-2011 at 04:54 PM..
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Upgrading bash on Darwin (osx)

Hi, I have installed bash 3.2 via darwin ports, however when I try and change the shell i.e. chsh -s /opt/local/bin/bash is says its a non-standard shell? but if i run ./bash i get a new bash prompt with version 3.2? Thanks (3 Replies)
Discussion started by: c19h28O2
3 Replies

2. Shell Programming and Scripting

how to make your bash script run on a machine with csh and bash

hi, i have a script that runs on bash and would like to run it on a machine that has csh and bash. the default setting on that machine is csh. i dont want to change my code to run it with a csh shell. is there any way i can run the script (written in bash) on this machine? in other words is there... (3 Replies)
Discussion started by: npatwardhan
3 Replies

3. Shell Programming and Scripting

#!/bin/bash and #1bin/sh command not found error on mac osx terminal/shell script

i am having a weird error on mac os x running some shell scripts. i am a complete newbie at this and this question concerns 2 scripts. one of which a friend of mine wrote (videochecker.sh) a couple weeks ago and it's been running fine on another machine. then last week i wrote capture.sh and it... (2 Replies)
Discussion started by: danpaluska
2 Replies

4. UNIX for Dummies Questions & Answers

Mac OSX Cron Script Execution

Hello, On Mac OSX, I was wondering about my Cron Script: HELL=/bin/tcsh PATH=/sbin:/bin:/usr/sbin:/usr/bin HOME=/var/log MAILTO=jwillis 25 1 * * * root /Users/jwillis/Fbcmd\Scripts/DailyBirthday.scrmy returned message is: Subject: Cron... (3 Replies)
Discussion started by: jwillis0720
3 Replies

5. OS X (Apple)

Creating Shell Script for STIG Checklist MAC OSX 10.6

Hello, I am new to Mac OSX and shell scripting all together. I was wondering if anyone could help get me started in a few scenarios so that I would be able to automate checking a system against a STIG checklist. A STIG Checklist is a DoD Guideline for securing systems. Here is the first... (3 Replies)
Discussion started by: john3j04
3 Replies

6. Shell Programming and Scripting

open application with spaces in name [bash][OSX]

Hi guys, I'm new here and new to shell scripting so don't be hard on me I'm trying to create a bash script to restart a process by name in Mac OSX. I have no problem killing the application, the problem comes when launching it again. I managed to store the path in a variable lets say ... (8 Replies)
Discussion started by: jonathanwiesel
8 Replies

7. Shell Programming and Scripting

OSX, bash, cat with <<MARKER executing commands

I have a script that writes another script with cat >/usr/local/bin/myscript.sh <<EOF #!/bin/sh VAR=`run a command here` EOF Problem is, after this is run, I get: $ cat /usr/local/bin/myscript.sh #!/bin/sh VAR=result of command How do I stop that from happening with Macs... (2 Replies)
Discussion started by: jnojr
2 Replies

8. Shell Programming and Scripting

OSX bash & expect

I have a script that must perform a 'sudo' operation on each of a number of hosts. I'm trying to get expect working so I only have to enter it once, and have run into a couple of issues. First, several examples suggest to use: /usr/bin/expect <<EOD spawn ssh -t $host /usr/bin/sudo -v... (7 Replies)
Discussion started by: jnojr
7 Replies

9. Shell Programming and Scripting

How to block first bash script until second bash script script launches web server/site?

I'm new to utilities like socat and netcat and I'm not clear if they will do what I need. I have a "compileDeployStartWebServer.sh" script and a "StartBrowser.sh" script that are started by emacs/elisp at the same time in two different processes. I'm using Cygwin bash on Windows 10. My... (3 Replies)
Discussion started by: siegfried
3 Replies

10. UNIX for Beginners Questions & Answers

In Bash shell - the ps -ef shows only the /bin/bash but the script name is not displayed

In Bash shell - the ps -ef shows only the /bin/bash but the script name is not displayed ? Is there any way to get the script names for the process command ? --- Post updated at 08:39 AM --- in KSH (Korn Shell), my command output shows the script names but when run in the Bash Shell... (3 Replies)
Discussion started by: i4ismail
3 Replies
String::Errf(3pm)					User Contributed Perl Documentation					 String::Errf(3pm)

NAME
String::Errf - a simple sprintf-like dialect VERSION
version 0.006 SYNOPSIS
use String::Errf qw(errf); print errf "This process was started at %{start}t with %{args;argument}n. ", { start => $^T, args => 0 + @ARGV }; ...might print something like: This process was started at 2010-10-17 14:05:29 with 0 arguments. DESCRIPTION
String::Errf provides "errf", a simple string formatter that works something like "sprintf". It is implemented using String::Formatter and Sub::Exporter. Their documentation may be useful in understanding or extending String::Errf. DIFFERENCES FROM SPRINTF
The data passed to "errf" should be organized in a single hashref, not a list. Formatting codes require named parameters, and the available codes are different. See "FORMATTING CODES" below. As with most String::Formatter formatters, "%" is not a format code. If you want a literal "%", do not put anything between the two percent signs, just write "%%". FORMATTING CODES "errf" formatting codes require a set of arguments between the "%" and the formatting code letter. These arguments are placed in curly braces and separated by semicolons. The first argument is the name of the data to look for in the format data. For example, this is a valid use of "errf": errf "The current time in %{tz}s is %{now;local}t.", { tz => $ENV{TZ}, now => time, }; The second argument, if present, may be a compact form for multiple named arguments. The rest of the arguments will be named values in the form "name=value". The examples below should help clarify how arguments are passed. When an argument appears in both a compact and named form, the named form trumps the compact form. The specific codes and their arguments are: s for string The "s" format code is for any string, and takes no arguments. It just includes the named item from the input data. errf "%{name}s", { name => 'John Smith' }; # returns "John Smith" Remember, "errf" does not have any of the left- or right-padding formatting that "sprintf" provides. It is not meant for building tables, only strings. i for integer The "i" format code is used for integers. It takes one optional argument, "prefix", which defaults to the empty string. "prefix" may be given as the compact argument, standing alone. "prefix" is used to prefix non-negative integers. It may only be a plus sign. errf "%{x}i", { x => 10 }; # returns "10" errf "%{x;+}i", { x => 10 }; # returns "+10" errf "%{x;prefix=+}i", { x => 10 }; # returns "+10" The rounding behavior for non-integer values is not currently specified. f for float (or fractional) The "f" format code is for numbers with sub-integer precision. It works just like "i", but adds a "precision" argument which specifies how many decimal places of precision to display. The compact argument may be just the prefix or the prefix followed by a period followed by the precision. errf "%{x}f", { x => 10.1234 }; # returns "10"; errf "%{x;+}f", { x => 10.1234 }; # returns "+10"; errf "%{x;.2}f", { x => 10.1234 }; # returns "10.12"; errf "%{x;+.2}f", { x => 10.1234 }; # returns "+10.12"; errf "%{x;precision=.2}f", { x => 10.1234 }; # returns "10.12"; errf "%{x;prefix=+;precision=.2}f", { x => 10.1234 }; # returns "+10.12"; t for time The "t" format code is used to format timestamps provided in epoch seconds. It can be given two arguments: "type" and "tz". "type" can be either date, time, or datetime, and indicates what part of the timestamp should be displayed. The default is datetime. "tz" requests that the timestamp be displayed in either UTC or the local time zone. The default is local. The compact form is just "type" alone. # Assuming our local time zone is America/New_York... errf "%{x}t", { x => 1280530906 }; # "2010-07-30 19:01:46" errf "%{x;type=date}t", { x => 1280530906 }; # "2010-07-30" errf "%{x;type=time}t", { x => 1280530906 }; # "19:01:46" errf "%{x;type=datetime}t", { x => 1280530906 }; # "2010-07-30 19:01:46" errf "%{x;tz=UTC}t", { x => 1280530906 }; # "2010-07-30 23:01:46 UTC" errf "%{x;tz=UTC;type=date}t", { x => 1280530906 }; # "2010-07-30 UTC" errf "%{x;tz=UTC;type=time}t", { x => 1280530906 }; # "23:01:46 UTC" errf "%{x;tz=UTC;type=datetime}t", { x => 1280530906 }; # "2010-07-30 23:01:46 UTC" n and N for numbered The "n" and "N" format codes are for picking words based on number. It takes two of its own arguments, "singular" and "plural", as well as "prefix" and "precision" which may be used for formatting the number itself. If the value being formatted is 1, the singular word is used. Otherwise, the plural form is used. errf "%{x;singular=dog;plural=dogs}n", { x => 0 }; # 0 dogs errf "%{x;singular=dog;plural=dogs}n", { x => 1 }; # 1 dog errf "%{x;singular=dog;plural=dogs}n", { x => 2 }; # 2 dogs errf "%{x;singular=dog;plural=dogs}n", { x => 1.4 }; # 1.4 dogs errf "%{x;singular=dog;plural=dogs;precision=1}n", { x => 1.4 }; # 1.4 dogs errf "%{x;singular=dog;plural=dogs;precision=0}n", { x => 1.4 }; # 1 dog If "N" is used instead of "n", the number will not be included, only the chosen word. errf "%{x;singular=is;plural=are}N", { x => 0 }; # are errf "%{x;singular=is;plural=are}N", { x => 1 }; # is errf "%{x;singular=is;plural=are}N", { x => 2 }; # are errf "%{x;singular=is;plural=are}N", { x => 1.4 }; # 1.4 are errf "%{x;singular=is;plural=are;precision=1}N", { x => 1.4 }; # 1.4 are errf "%{x;singular=is;plural=are;precision=0}N", { x => 1.4 }; # 1 is The compact form may take any of the following forms: word - equivalent to singular=word word+suffix - equivalent to singular=word;plural=wordsuffix word1/word2 - equivalent to singular=word;plural=word2 If no singular form is given, an exception is thrown. If no plural form is given, one will be generated according to some basic rules of English noun orthography. AUTHOR
Ricardo Signes <rjbs@cpan.org> COPYRIGHT AND LICENSE
This software is copyright (c) 2010 by Ricardo Signes. This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself. perl v5.12.3 2010-10-29 String::Errf(3pm)
All times are GMT -4. The time now is 08:39 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy