Command substition with KSH


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Command substition with KSH
# 1  
Old 02-11-2009
Command substition with KSH

$var=`command <arg> <arg>`

I thought there was another method

$var=$(command <arg> <arg>)

I thought I read saw the second example. It doesnt work
# 2  
Old 02-11-2009
Quote:
Originally Posted by popeye
$var=`command <arg> <arg>`

I thought there was another method

$var=$(command <arg> <arg>)

I thought I read saw the second example. It doesnt work

What does "doesn't work" mean? What does happen?

Both versions work in all flavours of ksh.

(I assume that the dollar signs at the beginning of your examples are your prompt, and not part of the command.)
# 3  
Old 02-12-2009
Perhaps you are thinking about ${ command;} command substitution which was added to ksh93 circa mid-2007. It behaves like $(command) except that command is executed in the current shell environment.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

sed substition within XML tag

Hi all, I basically want to remove certain characters from within a certain XML tag: From: <mytagone>hello 1-2-3 world</mytagone> <mytagtwo>hello 1-2-3 world</mytagtwo> To: <mytagone>hello 1 2 3 world</mytagone> <mytagtwo>hello 1-2-3 world</mytagtwo> Is this possible using sed... (6 Replies)
Discussion started by: Jedimark
6 Replies

2. Shell Programming and Scripting

command timeout in ksh

I probably read all the threads in almost all the forums for a solution to my need. I am a beginner in shell scripting and I dont have a perfect solution yet. Below is my code snippet. idql -n $REPOSITORY_NAME.$cs -Udmadmin -P"" -R$DM_SCRIPTS/test.api > /dev/null 2>&1 if ; then echo... (7 Replies)
Discussion started by: vishnudev1
7 Replies

3. UNIX for Dummies Questions & Answers

Help with variable substition in sed

Hi, I'm a bit stuck trying to get my sed syntax quite right for what I'm trying to do. I have a list of directories in a file and am trying to remove some of them using sed. I can do it if I specify the directory I want to remove in the sed command and escape the "/"s like so: say I... (2 Replies)
Discussion started by: derndingle
2 Replies

4. Shell Programming and Scripting

KSH command completions.

I want to do the Auto command completion in ksh for my product's CLI. For that I am using the key binding mechanism. But am stuck at following points. 1. I am not able to use .sh.edtext variable while KEYBD trap. As I know this variable contains Characters in the input buffer during... (1 Reply)
Discussion started by: Surendra_Singh
1 Replies

5. Programming

KSH command completions.

I want to do the Auto command completion in ksh for my product's CLI. For that I am using the key binding mechanism. But am stuck at following points. 1. I am not able to use .sh.edtext variable while KEYBD trap. As I know this variable contains Characters in the input buffer during... (1 Reply)
Discussion started by: Surendra_Singh
1 Replies

6. UNIX for Advanced & Expert Users

Regular expression / regex substition on Unicode text

I have a large file encoded in Unicode that I need to convert to CSV. In general, I know how to do this by regular expression substitutions using sed or Perl, but one problem I am having is that I need to put a quotation mark at the end of each line to protect the last field. The usual regex... (1 Reply)
Discussion started by: thomas.hedden
1 Replies

7. Shell Programming and Scripting

awk/sed Command : Parse parameter file / send the lines to the ksh export command

Sorry for the duplicate thread this one is similar to the one in https://www.unix.com/shell-programming-scripting/88132-awk-sed-script-read-values-parameter-files.html#post302255121 Since there were no responses on the parent thread since it got resolved partially i thought to open the new... (4 Replies)
Discussion started by: rajan_san
4 Replies

8. UNIX for Dummies Questions & Answers

Perl Substition with multiple conditions

I have a text file that contains lines similar to the following: ----------------------------------------------------------- fall for setup CSHRC0 'gnd'; CSHR0 'gnd'; rise for setup rise for hold CSHRC0 'gnd'; CSHR0 'gnd'; fall for hold ... (4 Replies)
Discussion started by: EDALBNUG
4 Replies

9. Shell Programming and Scripting

how does this substition work?

Hi all, Would like to know how these substitution works?? FINISHED="Done" x=126 COLS=$((${x} -${#FINISHED} - 5)) here does the #FINISHED give the ascii value of "done" ,or how does it work? Thanks (1 Reply)
Discussion started by: wrapster
1 Replies

10. UNIX for Dummies Questions & Answers

ksh with bc command error

Hi, I don't understand why the below code gave me error message: worked: not found I am using ksh program. worked =`/usr/ucb/echo "scale=2; ($logend-$logstart)/3600" | bc` Thank you very much for your help! (1 Reply)
Discussion started by: cin2000
1 Replies
Login or Register to Ask a Question