Re: script

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Mon, May 22, 2006 at 12:20:39PM +0530, Kaushal Shriyan wrote:
> #!/bin/bash
> va=`cut -d"/" -f2 out`
> #cat out > va
> echo $va
> cd $va
> 
> The issue is that it doesnot cd to the directory after running the script 

The script is run in a subshell and can not affect your running shell's
working directory (unless you invoke it by ". script-filename", in which case
you are running its commands in the context of your running shell).

Observe:

    $ cat foo.sh
    #!/bin/sh
    cd /tmp

Just trying to execute the script:

    $ ./foo.sh
    $ pwd
    /home/kayvan

But, using "." to execute the commands in the current shell:

    $ . ./foo.sh
    $ pwd
    /tmp

Another solution if you want this to affect your shell is to use the "alias"
command or shell functions.

Read "man bash" and http://www.tldp.net/HOWTO/Bash-Prog-Intro-HOWTO.html

Best regards,

			---Kayvan
-- 
Kayvan A. Sylvan          | Proud husband of       | Father to my kids:
Sylvan Associates, Inc.   | Laura Isabella Sylvan, | Katherine Yelena (8/8/89)
http://sylvan.com/~kayvan | my beautiful Queen.    | Robin Gregory (2/28/92)

-- 
fedora-list mailing list
fedora-list@xxxxxxxxxx
To unsubscribe: https://www.redhat.com/mailman/listinfo/fedora-list
[Index of Archives]     [Older Fedora Users]     [Fedora Announce]     [Fedora Package Announce]     [EPEL Announce]     [Fedora Magazine]     [Fedora News]     [Fedora Summer Coding]     [Fedora Laptop]     [Fedora Cloud]     [Fedora Advisory Board]     [Fedora Education]     [Fedora Security]     [Fedora Scitech]     [Fedora Robotics]     [Fedora Maintainers]     [Fedora Infrastructure]     [Fedora Websites]     [Anaconda Devel]     [Fedora Devel Java]     [Fedora Legacy]     [Fedora Desktop]     [Fedora Fonts]     [ATA RAID]     [Fedora Marketing]     [Fedora Management Tools]     [Fedora Mentors]     [SSH]     [Fedora Package Review]     [Fedora R Devel]     [Fedora PHP Devel]     [Kickstart]     [Fedora Music]     [Fedora Packaging]     [Centos]     [Fedora SELinux]     [Fedora Legal]     [Fedora Kernel]     [Fedora OCaml]     [Coolkey]     [Virtualization Tools]     [ET Management Tools]     [Yum Users]     [Tux]     [Yosemite News]     [Gnome Users]     [KDE Users]     [Fedora Art]     [Fedora Docs]     [Asterisk PBX]     [Fedora Sparc]     [Fedora Universal Network Connector]     [Libvirt Users]     [Fedora ARM]

  Powered by Linux