I'm looking at a script for a pushd function in my bash book:
Wanted to ask if someone could explain what's gong on. I've got most of it, but it's the second line that gets me. When a directory name is entered after the function and it's valid, what exactly is happening? I mean, why the two expressions?
Is it as simple as the function adding the just entered directory (assuming it's valid) to the stack, so that you have
just entered directory/original directory
which, the first time you do this, would evaluate to
just entered directory/pwd
and then the next valid directory would be
second valid directory/previously entered valid directory/pwd
and so on, correct?
so if you enter echo $DIRSTACK you'd get a list of all the entered directories.
But what if you enter a directory that doesn't exist? The book says that it cd fails, but still pushes the bad directory on to the stack. I tried that and I don't think that's what happens (I'm using Darwin (BSD) on my iMac, with Snow Leopard 6.3
if I enter an invalid directory I just get the value of PWD, but not the bad directory that the book says is supposed to be pushed on to DIRSTACK, only a message that says 'No such file or directory'
the book is "Learning the bash shell, third edition" and was written in 2005, covering bash 3.0. Is there something different about bash 3.2, which is on my Mac?
Last edited by Franklin52; 05-04-2010 at 04:55 AM..
Reason: Please use code tags!
I want to make a config file which contain all the paths.
i want to read the config file line by line and pass as an argument on my below function.
Replace all the path with reading config path line by line and pass in respective functions.
how can i achieve that?
Kindly guide.
... (6 Replies)
The file starts like this:
Directory: <path to the script>
Script: <script fife name>
#!bin/ksh
##Comments
<actual script>
What is the use of the first two lines in the script? What if I save the file without them? What will be the effect? They are not comments. Im very new to this,... (4 Replies)
Hi Team -
I"m very new to Shell Scripting so I have a rather novice question. My forte is Windows Batch Scripting so I was just wondering what the Shell Script equivalent is to the DOS command %~n?
%~n is a DOS variable that dispayed the script name.
For instance (in DOS):
REM... (11 Replies)
I've 2 shell scripts viz., CmnFuncs.ksh and myScript.ksh.
1st script contains all common functions and its code is as below:
$vi CmnFuncs.ksh
#!/bin/ksh
RunDate()
{
....
....
export Rundt=`date +%Y%m%d`
}
2nd script is invoking the above one and I expect to use the RunDt variable... (8 Replies)
hi everyone
i am trying to do this
bash> cat abc.sh
deepak()
{
echo Deepak
}
deepak
bash>./abc.sh
Deepak
so it is giving me write simply i created a func and it worked
now i modified it like this way
bash> cat abc.sh (2 Replies)
please help me in this script
shell script :1
***********
>cat file1.sh
#!/bin/bash
echo "this is first file"
function var()
{
a=10
b=11
}
function var_1()
{
c=12
d=13 (2 Replies)
Legends,
Can you please debug, what's wrong with the below code.
I am gettng unexpected token error
RebuldPF()
(
#Changing the directory to data directory where the pf exists.
cd /home/sandeep/files
#Listing the names of the Pricefiles for rebuilding
echo "The following pricefiles will... (6 Replies)
This is my function which is creating three variables based on counter & writing these variable to database by calling another function writeRecord
but only one record is getting wrote in DB.... Please advise ASAP...:confused:
function InsertFtg
{
FTGSTR=""
echo "Saurabh is GREAT $#"
let... (2 Replies)
Dear Friends,
I am on SOLARIS 9 (ksh)
I am working on a shell script that upload files with NcFTP with resume option. So far the script is working correctly. The script makes a list of files that need to be transferred and then launch the NcFTP command to start the transfer.
... (0 Replies)
Let say there is a module fileselection module written in c language which returns the file name. Is it possible to get the file name from the file selection module directly, I mean can we call a c function directly in shell script without doing executable. If possible then how it can be... (1 Reply)