08-27-2018
Be careful with this approach! If you don't understand what you are doing, you can easily end up with code which produces no error and works fine with your current set of data, and blows up or does something strange if your data look a little bit different (files missing, spaces in filenames and so on). Not nice if, for instance, half of your files get deleted because of a mistake in your program. Happens much easier in bash than in C++. Better ask here in the forum, if there is a construct which you don't understand.
10 More Discussions You Might Find Interesting
1. Shell Programming and Scripting
I have a program to create a directory if not present. Here is the program.
FYI: Directory name format: YYYY_MM_DD
#!/bin/bash
date=`date +%Y_%m_%d`
presence=$(ls -lrt /TS_File/ | grep "$date" | awk '{print $9}')
if
then
mkdir /TS_File/$date
else
echo "Unable to Create... (5 Replies)
Discussion started by: nthiruvenkatam
5 Replies
2. Shell Programming and Scripting
In my script I'm retrieving a parameter through an API call. I need to trim some things out of the result so I can use it as a parameter to pass to another process. I've got it working but it's pretty kludgy and I'm hoping someone can help me with a better way.
This is the code that retrieves... (2 Replies)
Discussion started by: withanh
2 Replies
3. Shell Programming and Scripting
Hi,
The following assigment is not working within shell script but is working from command line. Could anybody advise why? OS - solaris 8
APPL=`grep "$Application" ldapapps |awk '{print $1}'`
echo $APPL (5 Replies)
Discussion started by: urello
5 Replies
4. UNIX for Dummies Questions & Answers
I'm going freakin crazy here! I've tried multiple attempts and configurationa and cannot get this to work.
I have a file:
private/etc/apt/sources.list.d/cydia.list
I want to replace a string in this file:
"deb http:name.of.address ./"
with
"deb http:name.of.other.address ./"
The... (4 Replies)
Discussion started by: thazsar
4 Replies
5. Shell Programming and Scripting
Hy friends, I am newbie to bash scripting, can anyone explain how b=${a/23/BB} # Substitute "BB" for "23". this line converts "b" into string and and "d" into Integer. Thanks in advance (4 Replies)
Discussion started by: Qazi
4 Replies
6. Shell Programming and Scripting
Hello All,
I'm trying to assign integer values to variables using substitution in both the value and variable's name, i.e.,
number$x=$x
where x is equal to one in the first assignment, two in the second assignment, and so on with x being incremented each time.
However, when I do the... (7 Replies)
Discussion started by: tombombadil
7 Replies
7. Shell Programming and Scripting
If i'm given a string like "abc-def-1.2.3", how would I return "1"? I'm new to scripting and got stumped on this problem. Thanks in advance! (7 Replies)
Discussion started by: atsim
7 Replies
8. Shell Programming and Scripting
Sorry for my english i am french
So i am receiving from a script this prompt :
tabular;critical;mirroring;DG INTlocaldg VOLUME appears
tabular;critical;mirroring;DG INTlocaldg VOLUME bh3vm
tabular;critical;mirroring;DG INTlocaldg VOLUME dev
tabular;critical;mirroring;DG INTlocaldg VOLUME... (3 Replies)
Discussion started by: cterra
3 Replies
9. Shell Programming and Scripting
I figured this forum needs some laughs , so I am posting this.
And if the answer is - it depends on bash version - do not reply.
This is from "manual"
while CONTROL-COMMAND; do CONSEQUENT-COMMANDS; done
And here is the REAL code - no ";"
while do xterm & i=$ done (2 Replies)
Discussion started by: annacreek
2 Replies
10. UNIX for Beginners Questions & Answers
Hi,
I am new in bash scripting. In my work, I provide support to several users and when I connect to their computers I use the same admin and password, so I am trying to create a script that will only ask me for the IP address and then connect to the computer without having me to type the user... (5 Replies)
Discussion started by: arcoa05
5 Replies
LEARN ABOUT HPUX
xtsetarg
XtSetArg() XtSetArg()
Name
XtSetArg - set a resource name and value in an argument list.
Synopsis
void XtSetArg(arg, resource_name, value)
Arg arg;
String resource_name;
XtArgVal value;
Inputs
arg Specifies the Arg structure to set.
resource_name
Specifies the name of the resource.
value Specifies the value of the resource, or its address.
Description
XtSetArg() sets arg.name to resource_name, and sets arg.value to value. If the size of the resource is less than or equal to the size of
an XtArgVal, the resource value is stored directly in value; otherwise, a pointer to it is stored in value.
XtSetArg() is implemented as the following macro:
#define XtSetArg(arg, n, d) ((void)( (arg).name = (n), (arg).value = (XtArgVal)(d) ))
Because this macro evaluates arg twice, you must not use an expression with autoincrement, autodecrement or other side effects for this
argument.
Usage
Many Intrinsics functions need to be passed pairs of resource names and values in an ArgList to set or override resource values. XtSe-
tArg() is used to set or dynamically change values in an Arg structure or ArgList array.
Note that in Release 4, a number of functions beginning with the prefix XtVa were added to the Intrinsics. These functions accept a NULL-
terminated variable-length argument list instead of a single ArgList array. Often these forms of the functions are easier to use.
Example
XtSetArg() is usually used in a highly stylized manner to minimize the probability of making a mistake; for example:
Arg args[20];
int n;
n = 0;
XtSetArg(args[n], XtNheight, 100); n++;
XtSetArg(args[n], XtNwidth, 200); n++;
XtSetValues(widget, args, n);
Incrementing the array index on the same line means that resource settings can be easily read, inserted, deleted or commented out on a
line-by-line basis. If you use this approach, be careful when using XtSetArg() inside an if statement-don't forget to use curly braces to
include the increment statement.
Alternatively, an application can statically declare the argument list:
static Args args[] = {
{XtNheight, (XtArgVal) 100},
{XtNwidth, (XtArgVal) 200},
};
XtSetValues(Widget, args, XtNumber(args));
Structures
The Arg and ArgList types are defined as follows:
typedef struct {
String name;
XtArgVal value;
} Arg, *ArgList;
The definition of XtArgVal differs depending on architecture-its purpose is precisely to make code portable between architectures with dif-
ferent word sizes.
See Also
XtMergeArgLists(1), XtNumber(1).
Xt - Argument Lists XtSetArg()