Sponsored Content
Top Forums Shell Programming and Scripting How to put output of one command into a variable Post 302409031 by Jairaj on Wednesday 31st of March 2010 04:57:25 AM
Old 03-31-2010
Try this:

Code:
#!/bin/sh
st='cat /home/state'
if [ "$st" = "CA" ]
then
do_this
else
do_that
fi


Last edited by pludi; 03-31-2010 at 06:10 AM.. Reason: code tags, please...
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Command output to a variable.

With cut -c 8-13 myfile, I am getting some numeric value. In my shell script I am trying to assign something like this, var=cut -c 8-13 myfile But at the time of execution I am getting -c is not found. If I dont assign, then script executes well. Can we not simply use the value from one... (8 Replies)
Discussion started by: videsh77
8 Replies

2. UNIX for Dummies Questions & Answers

How to store output in variable when put in background

Hi, How do I store following command output: export RESULT=`date` & It works when I do : export RESULT=`date` But what I need is when command put it background, I also need that output going to RESULT variable. Is there any way ? Thanks Sanjay (1 Reply)
Discussion started by: sanjay92
1 Replies

3. Shell Programming and Scripting

Put the output of grep in a variable

Hi, in a shell script how can I put the result of a grep command in a variable : myvariable=grep mystring myfilename Thank you. (3 Replies)
Discussion started by: big123456
3 Replies

4. Shell Programming and Scripting

get characters from output of a command in a variable

Hi, i have two questions, I am new to programming 1. I have an output of a command and i want to get some specific part of it in a variable. i am trying sr=`some comand xyz| grep 'Last Changed Rev:' | cut -c19-` now variable sr gets a end of line character at end. output of the command... (3 Replies)
Discussion started by: muaz
3 Replies

5. Programming

Command output into a variable

Hi, with this command: cu -l /dev/ttyACM0 -s 9600 > name.txt I put the output of the port in a txt Is posible to do the same (or similar) in a var directly, inside a C program? cu -l /dev/ttyACM0 -s 9600 > variable ? I have trying this withs pipes, but i dont know how to... (6 Replies)
Discussion started by: daaran
6 Replies

6. Shell Programming and Scripting

set variable to command output

I'm hoping you guys can help me out here. I've been trying different methods to try and get what IW as hoping would be a fairly simple script but has turned into a pain. Bit of background - I am writing a script to check values in certain failes to ensure they are corerct. I'm runnign this on... (2 Replies)
Discussion started by: stuc
2 Replies

7. Shell Programming and Scripting

how to save an output of a command in a variable

Hi, in shell script, i have the command swstart -p which returns an output. i want to store the output of this command into a variable. how i can do that excerpt from the script #!/usr/bin/ksh # # # # Program: swstart -p # # Description: Starts the sentinels on Slave server ... (4 Replies)
Discussion started by: lookinginfo
4 Replies

8. UNIX for Advanced & Expert Users

ls output into a read command as a variable

I'm working on a short BASH script on my Ubuntu box that will run powerpoint scripts with MS Powerpoint Viewer 2007 via WINE. I can run the presentation when I run it manually but what i'd like to do is have the script look for the newest file then run it. #! /bin/sh # Start the newest... (2 Replies)
Discussion started by: binary-ninja
2 Replies

9. Shell Programming and Scripting

How i can put the result of a command inside a bash variable?

#!/bin/bash #... for i in `ls -c1 /usr/share/applications` do name="cat $i | grep ^Name= | cut -d = -f2" echo $name #... done Now inside name as output is present: while i want only the result of the command. Ideally i would like obtain that information using only bash ... or... (8 Replies)
Discussion started by: alexscript
8 Replies

10. Shell Programming and Scripting

Shell script variable $1 used with put command

I have the following script used, i am new to shell scripting. tryign to understand. in the put $BASE_FOLDER/$base_name holds which path. What does it mean by $1 second path in put command is it constructing this path: /user/hive/warehouse/stage.db/$1 what is $1 holding in above path. ... (2 Replies)
Discussion started by: cplusplus1
2 Replies
vbbatch(1)							 The VoxBo Manual							vbbatch(1)

NAME
vbbatch - run a command line multiple times with variable substitution SYNOPSIS
vbbatch <flag> ... DESCRIPTION
vbbatch is part of the VoxBo suite of tools for brain image analysis. vbbatch allows you to run a command multiple times with some variable substitutions (typically replacing the token FILE with each of a set of filenames). The commands are then run in parallel. If a VoxBo cluster is detected, the jobs will be submitted to the cluster. OPTIONS
EXAMPLES
To run myscript.sh on all your subjects' Anatomy directories: vbbatch -c "myscript.sh FILE" study*/sub*/Anatomy -r To run myperms.sh 1000 times at low priority, with different output files: vbbatch -c "myperms.sh results_IND.nii.gz" -d 1000 -r -p xnice AVAILABILITY
Pre-built VoxBo binaries are available for Linux, OSX, and Cygwin, and via the NeuroDebian project (neuro.debian.net) for Debian deriva- tives. CAVEATS
VoxBo is provided with no warranty whatsoever. AUTHOR
For an historical roster of the VoxBo development team, visit www.voxbo.org. SEE ALSO
For detailed help on any VoxBo command-line program, run it with no arguments. For graphical programs, use the -h flag. For more help with VoxBo, for information about the mailing list, or to report bugs, visit the web site at www.voxbo.org. For information about file format support in VoxBo, see voxbo-fileformats(7). For general information about VoxBo, see voxbo(7). VoxBo January, 2011 (v1.8.5) vbbatch(1)
All times are GMT -4. The time now is 10:28 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy