0
votes
2answers
54 views

Shell script to work on files in some directory

I am a noob in Linux hence this might come as a silly question. I have a Windows system, so I downloaded cygwin to help me execute Linux/unix commands. I need to execute a shell script on a bunch of ...
2
votes
2answers
27 views

How can I quickly return back to the last working directory? [duplicate]

All too often I find myself cycling between two directories to perform different tasks. The directories don't always have an easy-to-use relative path between them. As a result it is quite cumbersome ...
2
votes
2answers
100 views

Change directory based on a pipeline's output

I want to go to a directory with using filter For example there is a file named this-is-awsome ls | grep this-is-awsome | xargs cd How can I go to a directory with filter?
7
votes
4answers
621 views

Combined `mkdir` and `cd`? [duplicate]

is there any way (what is the easiest way in bash) to combine the following: mkdir foo cd foo The manpage for mkdir does not describe anything like that, maybe there is a fancy version of mkdir? I ...
19
votes
6answers
3k views

where is `cd` located? [duplicate]

In a bash sub shell I get the following error when running cd sudo: cd: command not found This is expected because I don't have a path. Usually to work around this I just provide the full path like ...
6
votes
3answers
772 views

is it possibe to change parent shell's working directory programmatically?

I want to write some code to allow me switching to some directories that I usually go to. Say this program is mycd, and /a/very/long/path/name is the directory that I want to go to. So I can simply ...
0
votes
2answers
174 views

Is CDPATH behavior broken in bourne shell (/bin/sh)

I have the following script: #!/bin/sh mkdir -p /tmp/test/foo cd /tmp/test unset CDPATH echo "TEST1: Current working directory: ${PWD}" echo "TEST1: attempting to 'cd foo'" cd foo echo "TEST1: ...
20
votes
4answers
2k views

Automatically detect when I typed “vi” but meant “cd”?

Title says it all. About 5 times a day, I type "vi" when I meant "cd", and end up opening a directory in vi. It's making me NUTS. It seems like there should be a way to detect when I type in "vi + ...
3
votes
1answer
125 views

How to cd into a directory with the name “-”? [duplicate]

I tried to cd into a directory named - that I created for experimenting. I could not from Bash. How do I cd into it? With Nautilus on Ubuntu 13.10 I could easily do this, and even create files inside ...
3
votes
1answer
96 views

script to remember dir and always cd to it instead of the root dir

How can write a script to change to a given directory but also remember it so that when you do cd it always changes to that directory ? #!/bin/bash setdir() { cd $1 # remember the directory ...
3
votes
1answer
58 views

How to cd open / autocomplete a folder that ends in a specific phrase

I have a folder with subfolders named like this: 1122334 important things 1122335 less important things 1122336 notes 1122337 pictures of kittens etc The numbers at the beginning are date codes. ...
2
votes
3answers
179 views

Simplified navigation in terminal

I know IDEs are the wave of the future, but I always find myself coding in vim in a Linux terminal. Old dog. New tricks. Anyway, navigation becomes challenging when dealing with long package names. ...
43
votes
6answers
3k views

Is there a way to cd back multiple times in bash?

I often use cd - to go back to where I was. How can I do this multiple times in bash? Or would zsh or some other tool support this?
0
votes
1answer
69 views

How do I change working directories with KDialog?

Use-case: I am working in the terminal in /path/with/a/very/long/name and I want to change to some other directory that is deeply nested. But I don't know the path by memory. So I want to browse via a ...
3
votes
3answers
201 views

Quick access to work directory of background job

Minimal effort to reproduce what I am looking for, is as follows /$ sleep 1h & [1] 6564 /$ cd ~$ jobs [1]+ Running sleep 1h & (wd: /) When I use jobs to manage my ...
5
votes
2answers
2k views

How can I cd into a directory as root?

Let's say there's a directory that I don't have the privileges to access. Obviously sudo cd foo won't work, because cd is a shell builtin in every shell ever. So far, I've just been using sudo bash ...
2
votes
1answer
113 views

Why does cd default to ~?

When you type cd, it basically does the same thing as cd ~. Why? I'm wondering if it's just a hard-coded behavior or if bash is expanding the command or something.
2
votes
1answer
112 views

An -e option to cd builtin

According to Bash reference on Bash builtins: cd [-L|[-P [-e]]] [directory] The -P option means to not follow symbolic links; symbolic links are followed by default or with the -L option. ...
4
votes
1answer
197 views

How do I cd up and down again with symlinks in bash?

Structure: /base/ +- somedir/ +- symlink/ -> /some_other_dir This command (in addition to my Makefiles) fails: cd /base/symlink ls ../somedir Bash complains that ../somedir does not ...
3
votes
2answers
1k views

How to make cd arguments case INsensitive?

Sometimes while accessing the various directories it happens most of the times that I remember the names or at least part of the names of a directory under our Linux system. But some of the ...
2
votes
2answers
152 views

Does a parent bash script remember the cd history from a child bash script?

Example: mainscript.sh cd /mnt/something ./buildscripts/000-script.sh 000-script.sh cd /mnt/otherthing mkdir something exit
12
votes
1answer
4k views

Make cd follow symbolic links

I have my code mounted as an sshfs in my home directory, but the hierarchy is difficult to remember, so I created a symlink in my home directory leading to that directory. Is there a way so that when ...
1
vote
1answer
124 views

How can I have cd show the directory it switches into?

I have made my command prompt ($PS1) to be just username.../current_directory (using the 3 dots because my directory structure has lots of levels and they were taking up too much of the command line ...
19
votes
3answers
2k views

How do you enter a directory that's name is only a minus?

I downloaded lessn to my webserver and unzipped it. It contains a folder named -. I assumed I know how to deal with that, but I don't. I tried cd -- -, but that doesn't have the desired effect. ...
5
votes
1answer
421 views

Symbolic links with ls, mv: forcing the functions to utilize “logical” addresses (remembering the original path)

It seems that for many basic functions operating on symbolic links, the physical path is used by default. However, cd works fine. When moving into a symbolic link, cd remembers where I came from so it ...
2
votes
5answers
2k views

Perl script, do cd on terminal

In Script to change current directory (cd, pwd) it is shown how to run a bash script that changes terminal directory. But how do i run a perl script that runs a bash script that changes terminal ...
6
votes
2answers
497 views

Run a script automatically as I switch to a directory [duplicate]

Possible Duplicate: Execute bash scripts on entering a directory I am running an environment which requires some very specific tool versions. The commands to set up the environment are in a ...
3
votes
2answers
118 views

How can I create a “base” for other aliases to refer to and enable cd base/x command directories?

I have .bash_aliases with: alias c1='cd /home/me/code/php' alias c2='cd /home/me/code/jquery' alias c3='cd /home/me/code/ruby' alias c4='cd /home/me/code/c' How can I DRY this up and loosen the ...
43
votes
4answers
2k views

cd by just typing the directory's name?

I either had this somewhere 20 years ago or I dreamed about it. Basically: If if type blobblob I get blobblob: command not found Fair enough. I would like it so that when my shell gets those ...
10
votes
4answers
4k views

symbolic link to a directory and relative path

I've created symlink with absolute path to the directory (Blink) and have for example following tree: $ ls -l /tmp/A total 0 lrwxrwxrwx 1 root root 6 Apr 3 12:27 Blink -> /tmp/B -rw-r--r-- 1 root ...
8
votes
5answers
4k views

How can I open a new terminal in the same directory of the last used one from a window manager keybind?

I'm using a tiling window manager and I switched from gnome-terminal with multiple tabs to multiple urxvt instances managed by the window manager. One of the features I miss is the ability to open a ...
4
votes
2answers
624 views

Conflict between `pushd .` and `cd -`

I am a happy user of the cd - command to go to the previous directory. At the same time I like pushd . and popd. However, when I want to remember the current working directory by means of pushd ., I ...
10
votes
4answers
9k views

Script to change current directory (cd, pwd)

I want to run a script to simply change the current working directory: #!/bin/bash cd web/www/project But, after I run it, the current pwd remains unchanged! How can I do that?
6
votes
2answers
214 views

Output of which command used for input to cd

I would like to take the output of a which command, and cd to the parent directory. For example, say I have the following: which someprogram With output: /home/me/somedirectory/someprogram And I ...
5
votes
1answer
207 views

Any cd shortcut to switch an intermediate directory in current path?

if I have current path as a long one..and I want to switch to a directory with just one word from path replaced by something else..like say when using maven , I want to switch from main path to test ...
19
votes
1answer
3k views

Execute bash scripts on entering a directory

What is the best way to execute a script when entering into a directory? When I move into a new directory I would like bash to execute the projectSettings.bash script much like RVM does.
6
votes
4answers
3k views

Make cd automatically ls

I find that I often do the following: %> cd bla/bla %> ls I would like it that whenever I cd into a directory it automatically does an ls. I fiddled with my .bashrc for a while, but couldn't ...
3
votes
1answer
359 views

bash: cd to the most recently modified child directory

Wondering if there's an easy and/or portable way to say "change to the most recently modified child directory." I can use ls and awk but there's probably a better way. cd $( ls -ltrd */ | tail -1 | ...
14
votes
6answers
9k views

Execute a specific command in a given directory without cd'ing to it?

Is there a way to execute a command in a different directory without having to cd to it? I know that I could simply cd in and cd out, but I'm just interested in the possibilities of forgoing the extra ...
14
votes
3answers
2k views

Changing parent directory (../) with symlinks

I have a symlink ~/link -> ~/a/really/long/path When I do cd ~/link cd .. it takes me to ~ but I want to go to ~/a/really/long Is there a way to do this? I am using bash.
9
votes
2answers
725 views

Change directory without typing cd?

Is it possible to make bash change directory in command line simply by typing that directory without any commands like cd? For example is it possible instead of writing this: $ cd /tmp I just want ...
17
votes
2answers
3k views

What is the bash shortcut to change to the previous directory?

Sadly, I only learned about this last year by stumbling upon it randomly on the internet. I use it so infrequently that I always forget what it is by the time I need it again. How do you change to ...