The UNIX and Linux Forums  


Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
shell programming nivas Shell Programming and Scripting 8 02-11-2008 12:06 PM
Aix Shell Programming akmtcs AIX 1 12-07-2006 08:40 AM
shell programming Neha Agarwal Shell Programming and Scripting 2 09-07-2005 03:23 AM
Shell Programming Help mec585858 UNIX for Dummies Questions & Answers 4 12-10-2003 10:24 AM
Shell Programming JWK1 UNIX for Dummies Questions & Answers 2 06-01-2001 02:31 PM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 09-28-2006
vgirijanaidu vgirijanaidu is offline
Registered User
  
 

Join Date: Sep 2006
Posts: 2
{} in shell programming

Could someone please tell me what {} mean when they surround a variable?

For instance,

$FILE = 'basename $1' //what is passed into this script
$BANK = 'dirname $1'
$INFILE = ${FILE}.${BANK}.$$

What does $INFILE contain after this assignment?

Please let me know
Thanks
G
  #2 (permalink)  
Old 09-28-2006
systemsb systemsb is offline
Registered User
  
 

Join Date: Jan 2006
Posts: 23
See below ....

$vi a.sh
ab=$(pwd)
echo " "
echo "Current working directory is $ab"
FILE=$(basename $ab)
echo "FILE returns $FILE "
echo " "
ab=$(pwd)
echo "Current working directory is $ab"
BANK=$(dirname $ab)
echo "BANK returns $BANK"
echo " "

INFILE=${FILE}.${BANK}.$$
echo $INFILE


dam@athena:~$ ./a.sh

Current working directory is /home/dam
FILE returns dam

Current working directory is /home/dam
BANK returns /home

dam./home.11937




Not sure what you are trying to achieve...

I think what you probably wanted was

/home/dam.11937
  #3 (permalink)  
Old 09-28-2006
Dhruva's Avatar
Dhruva Dhruva is offline
Registered User
  
 

Join Date: Mar 2006
Location: India
Posts: 255
{} is used for building strings.
Code:
FILE = 'basename $1'
the above line of code is taking first parameter passed to this script as argument.what basename command will do here is if you have given the filename with path like /abc/dir1/dir2/filename then the
Value of FILE that is $FILE will have value "filename".
Code:
BANK = 'dirname $1'
the above command will remove the filename and assign path of file to BANK.
BANK will be "/abc/dir1/dir2/"
Code:
INFILE = ${FILE}.${BANK}.$$
Now the INFILE will have value "filename./abc/dir1/dir2/.3456"
here $$ gives the process id. in unix each command will run as a process and generates id.and value of $$ may differ in each run.
  #4 (permalink)  
Old 09-28-2006
mdhmi mdhmi is offline
Registered User
  
 

Join Date: Sep 2006
Location: Detroit, Michigan
Posts: 23
Wow does this sound like a homework question.

What do you notice:

THIS=that
$ echo $THIS1
$ echo ${THIS}1
  #5 (permalink)  
Old 09-28-2006
srikanthus2002's Avatar
srikanthus2002 srikanthus2002 is offline
Registered User
  
 

Join Date: Sep 2006
Location: Can u guess...!
Posts: 160
#!/bin/bash
X=ABC
echo "$Xabc"

THis gives no output. What went wrong ? The answer is that the shell thought that we were asking for the variable Xabc, which is uninitialised. The way to deal with this is to put braces around X to seperate it from the other characters. The following gives the desired result:
#!/bin/bash
X=ABC
echo "${X}abc"

------------------

I think that it will clear your doubt.
still you are not getting ...pls give full details so that we can give a solution of same

Thanks
Ckanth
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 11:20 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0