command substitution doubt


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting command substitution doubt
# 1  
Old 05-10-2012
Question command substitution doubt

Hi,

I almost always use back quotes in scripts to assigin output of a command to a variable.
eg: file=`basename a/b/c/d/file`
year_mon=`date +%Y%m`

But the same can be achieved like:
file=$(basename a/b/c/d/file)
year_mon=$(date +%Y%m)

I would like to know if there is any advantage/disadvantage or performance issues for these methods. or Is it Ok to use any of these?

Thanks in advance!
# 2  
Old 05-10-2012
See if this gives any information you're looking for:
Useless use of backticks.
This User Gave Thanks to balajesuri For This Post:
# 3  
Old 05-10-2012
This User Gave Thanks to itkamaraj For This Post:
# 4  
Old 05-10-2012
Oh.. Thanks a lot for that itkamaraj. Smilie I need to switch to $() Smilie

---------- Post updated at 10:29 AM ---------- Previous update was at 10:28 AM ----------

Thank you Balajesuri...
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Regarding command substitution

Oracle Linux 5.6, 64-bit Given the following snippet wrkvar=`sqlplus -s / as sysdba <<EOF set echo off feedback off head off trimsp on select count(*) from v\$parameter where name in ('db_file_name_convert','log_file_name_convert') and value is not null; EOF` echo wrkvar=$wrkvarProduces... (2 Replies)
Discussion started by: edstevens
2 Replies

2. UNIX for Dummies Questions & Answers

Doubt in ls command

dear users and experts, i am stuck withis command and i am unable to understand what is it doing?? ls -d * (7 Replies)
Discussion started by: seshank
7 Replies

3. UNIX for Dummies Questions & Answers

read command - using output from command substitution

Hey, guys! Trying to research this is such a pain since the read command itself is a common word. Try searching "unix OR linux read command examples" or using the command substitution keyword. :eek: So, I wanted to use a command statement similar to the following. This is kinda taken... (2 Replies)
Discussion started by: ProGrammar
2 Replies

4. UNIX for Dummies Questions & Answers

sed insert command and variable expansion/command substitution

I know this script is crummy, but I was just messing around.. how do I get sed's insert command to allow variable expansion to show the filename? #!/bin/bash filename=`echo $0` /usr/bin/sed '/#include/ { i\ the filename is `$filename` }' $1 exit 0 (8 Replies)
Discussion started by: glev2005
8 Replies

5. Shell Programming and Scripting

sed command doubt

i have input files like this SFE_DOC_DATE (SFE_DOC_DATE:UniChar.:): "04/18/20" SFE_PSTNG_DATE (SFE_PSTNG_DATE:UniChar.:): "04/18/20" SFE_CREATEDON (SFE_CREATEDON:UniChar.:): "05/31/20" SFE_CLEAR_DATE (SFE_CLEAR_DATE:UniChar.:): "(NULL)" SFE_CLR_DOC_NO... (3 Replies)
Discussion started by: Gopal_Engg
3 Replies

6. Shell Programming and Scripting

Doubt variable substitution

Hello everybody, I've written the following script: vOutputFile="subs_out.txt" vAccount1="ebsemerg" vAccount2="ebsemer2" vAccount3="ebsemer3" vAccount4="ebsemer4" vAccount5="ebsemer5" vAccount="vAccount" vNumber=1234567 cd /opt/east/bin echo ${print 'vAccount'${ind}} for (( ind =... (3 Replies)
Discussion started by: jitu.jk
3 Replies

7. UNIX for Dummies Questions & Answers

doubt in tar command

Hello sir, We can archive a file by :tar -cvf a.tar a.txt AND We can get it back by : tar -xvf a.tar I want to save the file extracted from a.tar into a specific location.How can I give the destination path in the above command ??? (2 Replies)
Discussion started by: nsharath
2 Replies

8. Shell Programming and Scripting

Difference between "Command substitution" and "Process substitution"

Hi, What is the actual difference between these two? Why the following code works for process substitution and fails for command substitution? while IFS= read -r line; do echo $line; done < <(cat file)executes successfully and display the contents of the file But, while IFS='\n' read -r... (3 Replies)
Discussion started by: royalibrahim
3 Replies

9. UNIX for Dummies Questions & Answers

doubt in tr command

Hi, I am trying to understand a script and found a line as follows: tr '\211\233\240' '\040' < $IN_FILE | tr -cd '\11\12\15\40-\176' > $TEMP_FILE Can any one explain the above line .. What are they trying to translate using the tr command.. I have not used tr command.. so feeling little bit... (2 Replies)
Discussion started by: risshanth
2 Replies

10. Shell Programming and Scripting

Substitution of last command

"Is there any substituation of last command or script syntax which can be used as a user. As far I know the "last" command is being used to display information about previous logins. A member of adm group or the user adm can execute it only. Thanks in advance for your usual help. Ghazi (6 Replies)
Discussion started by: ghazi
6 Replies
Login or Register to Ask a Question