A bash script

Paul Howarth paul at city-fan.org
Thu Jan 6 15:21:51 UTC 2005


Chadley Wilson wrote:
> Greetings
> I am about to start a script for installing a couple of updates and I got this 
> far :
> 
> #!/bin/sh
> 
> echo "Starting install process ;-)"
> pwd
> 
> 
> Now the very first thing i need, is a thing I can't do
> ha ha!
> 
> The script will run from a folder probably called "updates"
> What I have never worked out was how to make the current working dir a 
> variable for this. As this folder could be copied anywhere in the file 
> system!
> so the script will have to work regardless of what the absolute path is. 
> Endusers can be stupid you know and make 10 copies of the folder before 
> getting the updates folder into the correct one.
> 
> I figured I would need to put in  a pwd command.
> 
> but how do you make the script recognise the pwd output as a variable?
> 
> Is there a simple example I cam work from?

This is a very elementary scripting question. Try the tutorial at 
http://pegasus.rutgers.edu/~elflord/unix/bash-tute.html. I'm sure others 
will mention other good scripting guides too.

What you're after is called command substitution, and you can do it like 
this:

# Set variable $updatedir to current directory
updatedir=$(pwd)

Paul.




More information about the fedora-list mailing list