Prev: Any example fvwm2rc files that mimic twm?
Next: What is the difference between "su" and "sudo" ?
From: j on 31 Dec 2009 20:12 "Chris F.A. Johnson" <cfajohnson(a)gmail.com> wrote in message news:7q15boFt02U2(a)mid.individual.net... > On 2009-12-30, ela wrote: >> cd - can go back one directory >> >> is there any way to go backwards several directories? (Not asking cd >> ../../ >> etc) > > n=2 > pushd "${DIRSTACK[@]:$n:1}" where should I place these 2 lines? I'm using tcsh and when i use sh test.sh the error prompts: test.sh: line 3: pushd: no other directory
From: j on 31 Dec 2009 20:37 "Sidney Lambe" <sidneylambe(a)nospam.invalid> wrote in message news:slrnhjm2m1.pga.sidneylambe(a)evergreen.net... > On comp.os.linux.misc, ela <ela(a)yantai.org> wrote: > > > Secondly, where did you put the function "d"? It should go in > your ~/.bashrc. > > Sourcing makes a script run in your current shell rather than > the default subshell. > > $ . scriptname > > $ source scriptname > > Those are two ways to do it. > > If you don't source the script it won't work. > > > If that doesn't fix it, try putting "set -x" just below > "#!/bin/bash" to troubleshoot the script. > > I use this script all the time. Couldn't live without it. > > > Sid > > > I believe your program will be indispensible to all unix users. First of all, i use tcsh instead of bash. after changing my sh to bash, I put the function d into .bashrc and source it. the dirstack.sh is placed into /usr/local/bin then I type "d" ok a b c etc prints out, but they are all empty. Finally, what should i modify if i want your prog to run under tcsh?
From: Chris F.A. Johnson on 31 Dec 2009 20:47 On 2010-01-01, j wrote: > > "Chris F.A. Johnson" <cfajohnson(a)gmail.com> wrote in message > news:7q15boFt02U2(a)mid.individual.net... >> On 2009-12-30, ela wrote: >>> cd - can go back one directory >>> >>> is there any way to go backwards several directories? (Not asking cd >>> ../../ >>> etc) >> >> n=2 >> pushd "${DIRSTACK[@]:$n:1}" > > where should I place these 2 lines? I'm using tcsh The code I posted is for bash; I don't use tcsh as it's not recommended for scripting, and there's no point to learning an entirely different shell language for interactive use. > and > > when i use sh test.sh > > the error prompts: > > test.sh: line 3: pushd: no other directory -- Chris F.A. Johnson, author | <http://cfajohnson.com> Shell Scripting Recipes: | My code in this post, if any, A Problem-Solution Approach | is released under the 2005, Apress | GNU General Public Licence
From: Sidney Lambe on 31 Dec 2009 21:24 On comp.os.linux.misc, j <jh(a)jl.n> wrote: > "Sidney Lambe" <sidneylambe(a)nospam.invalid> wrote in message > news:slrnhjm2m1.pga.sidneylambe(a)evergreen.net... > >> On comp.os.linux.misc, ela <ela(a)yantai.org> wrote: >> >> >> Secondly, where did you put the function "d"? It should go in >> your ~/.bashrc. >> >> Sourcing makes a script run in your current shell rather than >> the default subshell. >> >> $ . scriptname >> >> $ source scriptname >> >> Those are two ways to do it. >> >> If you don't source the script it won't work. >> >> >> If that doesn't fix it, try putting "set -x" just below >> "#!/bin/bash" to troubleshoot the script. >> >> I use this script all the time. Couldn't live without it. >> >> >> Sid >> >> > > I believe your program will be indispensible to all unix users. Thanks. I find it incredibly useful. It's part of a small suite of scripts that greatly facilitate running Linux from the commandline. I tried all the file managers and didn't like them. > First of all, i use tcsh instead of bash. after changing my sh > to bash, I put the function d into .bashrc and source it. the > dirstack.sh is placed into /usr/local/bin then I type "d" > > ok > > a b c etc prints out, but they are all empty. Could be that you use a different version of awk. See comp.lang.awk for help if that turns out to be the case. Putting "set -x" at the top will aid in troubleshooting the script. Might be a copying error. "cat -A" will show the non-printing characters. > > Finally, what should i modify if i want your prog to run under > tcsh? Don't know, See comp.unix.shell. OT: I suggest use a more conventional alias. I almost killfiled you and dumped your posts because you looked like a stinking troll. If you do change it, indicate that fact in your next post. Sid
From: Maxwell Lol on 2 Jan 2010 17:14 "ela" <ela(a)yantai.org> writes: > cd - can go back one directory > > is there any way to go backwards several directories? (Not asking cd ../../ > etc) well, cd with no argument goes to your home directory. Since you are using tcsh, you should use the built-ins pushd and popd. pushd remembers your current directory, and goes to a new one. popd returns you to your old directory. If you type pushd with no arguments, it changes place with the last directory. Also - when you do this - it shows you the current directory stack. You can pop back several directories by using a number. if your directory stack is /dir1 /dir2 /dir3 Then pushd +2 will take you to /dir3 instead of /dir1 You might also want to use this in your .cshrc file alias = 'set \!:1="$cwd"' This lets you "remember" a directory by a name. That is = Here then when you want to go to that directory, just type cd Here No $ is necessary.
First
|
Prev
|
Pages: 1 2 Prev: Any example fvwm2rc files that mimic twm? Next: What is the difference between "su" and "sudo" ? |