02-28-2008
Assigning output of command to a variable in shell
hi,
I want to assign find command result into some temporary variable:
jarPath= find /opt/lotus/notes/ -name $jarFile
cho "the jar path $jarPath"
where jarPath is temporary variable.
Can anybody help on this.
Thanks in advance
----Sankar
10 More Discussions You Might Find Interesting
1. Shell Programming and Scripting
Hi,
I'm trying to assign the output of a command to a variable and then concat it with another string, however, it keeps overwriting the original string instead of adding on to the end of the string.
Contents of test.txt --> This is a test
var1="`head -n 1 test.txt`"
echo $var1 (This is a... (5 Replies)
Discussion started by: oma04
5 Replies
2. Shell Programming and Scripting
I have the sql file cde.sql with the below contents:
abcdefghij
abcwhendefothers
sdfghj
when no one else
when others
wwhen%others
exception when others
Now I want to search for the strings containing when others together and ceck whether that does not occur more than once in the... (2 Replies)
Discussion started by: kprattip
2 Replies
3. Shell Programming and Scripting
Hello friends,
I doing the follwing script , but found problem to store it to a shell variable.
#! /bin/sh
for temp in `find ./dat/vector/ -name '*.file'`
do
echo $temp
nawk -v temp=$temp 'BEGIN{ split(temp, a,"\/"); print a}'
done
output:
./dat/vector/drf_all_002.file... (6 Replies)
Discussion started by: user_prady
6 Replies
4. Shell Programming and Scripting
I am new to unix shell scripting.
I was trying to convert each lines in a file to upper case.
I know how to convert the whole file.
But here i have to do line by line.
I am getting it in the below mentioned script
#!/bin/bash
#converting lower to upper in a file
#tr "" "" <file1... (3 Replies)
Discussion started by: jpmena
3 Replies
5. Shell Programming and Scripting
When I run time -p <command>, it outputs:
real X.XX
user X.XX
sys X.XXwhere X.XX is seconds. How I can take just that first number output, the seconds of real time, and assign that to a variable? (9 Replies)
Discussion started by: jeriryan87
9 Replies
6. Shell Programming and Scripting
First, this is bash (3.2.17), on a Mac, 10.5.7.
What I'm trying to do is look at a list of users, and check to see if each exists. If they do, do some more stuff, if they don't, drop them into an error file.
So, my user list is:
foo - exists
bar - does not exist
blah - does not exist
... (2 Replies)
Discussion started by: staze
2 Replies
7. Shell Programming and Scripting
I am trying to assgn the output of the select statement to a variable, like this
"VARIABLE_NAME=$ db2 "select COLUMN_NAME_1 from TABLE_NAME where COLUMN_NAME_2='VALUE_TO_CHECK'"; "
but the value that is getting into VARIABLE_NAME is
"COLUMN_NAME_1
-----------------
VALUE
1... (3 Replies)
Discussion started by: sgmini
3 Replies
8. UNIX for Dummies Questions & Answers
Hello
I am using unix CLI commands for the Synergy CM software. The command basically searches for a folder ID and returns the names of the projects the folder sits in. The result is assigned to a variable:
FIND_USE=`ccm folder -fu -u -f "%name"-"%version" ${FOLDER_ID}`
When the command... (6 Replies)
Discussion started by: Glyn_Mo
6 Replies
9. UNIX for Dummies Questions & Answers
Hi I have a text file with 2 values and I am trying to assign each value to a variable and then write those to text files.
So if the textfile is data.txt with 2 values x and y
I want to assign mean=x, and stdev=y and then write these out in text files alongwith the id ($id has already been... (6 Replies)
Discussion started by: violin
6 Replies
10. Shell Programming and Scripting
Hi,
I'm writing a script that connects through ssh (using "expect") and then is supposed to find whether a process on that remote machine is running or not. Here's my code (user, host and password are obviously replaced with real values in actual script):
#!/usr/bin/expect
set timeout 1... (3 Replies)
Discussion started by: oseri
3 Replies
tmpnam(3S) tmpnam(3S)
NAME
tmpnam(), tempnam() - create a name for a temporary file
SYNOPSIS
DESCRIPTION
and generate file names that can safely be used for a temporary file.
Always generates a file name using the path-prefix defined as
in the header file. If s is NULL, leaves its result in an internal static area and returns a pointer to that area.
The next call to destroys the contents of the area. If s is not NULL, it is assumed to be the address of an array of
at least bytes, where is a constant defined in places its result in that array and returns s. For multi-thread
applications, if s is a NULL pointer, the operation is not performed and a NULL pointer is returned.
allows the user to control the choice of a directory.
The argument dir points to the name of the directory in which the file is to be created. If dir is NULL or points to
a string that is not an appropriate directory name, the path-prefix defined as in the header file is used. If that
directory is not accessible, is used as a last resort. This entire sequence can be up-staged by providing an envi-
ronment variable in the user's environment, whose value is the name of the desired temporary-file directory.
In order to request the default behavior for either or a NULL value must be passed in dir and pfx for or in s for If valid parameters are
not passed in, behavior is undefined.
Many applications are written such that temporary files have certain initial character sequences in their names. Use the pfx argument to
define a given prefix. The argument can be NULL or point to a string of up to five characters to be used as the first characters in the
temporary-file name.
uses (see malloc(3C)) to get space for the constructed file name, and returns a pointer to this area. Thus, any pointer value returned
from can serve as an argument to (see malloc(3C)). If cannot return the expected result for any reason; i.e., failed, or none of the above
mentioned attempts to find an appropriate directory was successful, a NULL pointer is returned.
Notes
and generate a different file name each time they are called, but start recycling previously used names if called more than times in a sin-
gle process.
Files created using these functions and either or (see fopen(3S) and creat(2)) are temporary only in the sense that they reside in a direc-
tory intended for temporary use, and their names are unique. It is the user's responsibility to use unlink(2) to remove the file when it
is no longer needed.
WARNINGS
Between the time a file name is created and the file is opened, it is possible for some other process to create a file with the same name.
This can never happen if that other process is using these functions or and the file names are chosen such that duplication by other means
is unlikely.
SEE ALSO
creat(2), unlink(2), malloc(3C), mktemp(3C), fopen(3S), tmpfile(3S), thread_safety(5).
STANDARDS CONFORMANCE
tmpnam(3S)