Stack Exchange Network

Stack Exchange network consists of 175 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

Questions tagged [pwd]

For questions about the working directory of processes, as well as the `pwd` command

0
votes
1answer
32 views

Difficulty in undersanding pwd command

I am writing pwd in terminal, and it is showing home/<my_username>. But I cannot physically find any directory with this path. To clear my confusion, I typed ls, but it shows the folders in my ...
0
votes
1answer
24 views

Specifying path to a file within a program command line

I am using a program called Diamond and I have a script that goes like this: cd /srv/scratch/myname/hello diamond blastp -d /srv/scratch/myname/goodbye/inputFile1.dmnd -q inputFile2.faa -o /diamond/...
2
votes
0answers
32 views

Add file to PATH only when in specific directory [duplicate]

Is it possible to make executable appear in the global search path when I am entering to the some specific directory and get it removed once directory changed again?
0
votes
1answer
41 views

tcl cd/pwd command with regard to real/symbolic path

When I work under tcl environment, once I cd to a directory, even if the path I specify is its symbolic link, then no matter whether I run pwd -L or pwd -P, they all return the absolute path. This is ...
0
votes
1answer
87 views

When can a “cd” command fail in a shell script and what can I do to remedy it?

I have a shell script that failed to finish last week; it was a failed "cd" command and it exits if it fails. The script is a bash shell script for configuring new Debian installs. Here is the full ...
0
votes
2answers
53 views

How to run a command with a different working directory?

I use this shell pipeline to get a SQL dump using the terminal: $ cd var/lib/mysql && mysqldump -uroot -p"craft" --add-drop-table craft > ~/../docker-entrypoint-initdb.d/base.sql &&...
0
votes
1answer
198 views

Use SCP from local machine to recursively copy current working directory to remote?

Trying to do something like (in pseudo-unix): scp -r <pwd> username@remote.com:~/<dirname of toplevel> In other words, I'm trying to copy the current directory I'm in locally (and the ...
0
votes
2answers
135 views

tmux change default working directory of a session without attaching

I'm looking for a way to do something like this without attaching to the session. tmux attach-session -c <directory> -t <session> ^^^^^^^^^^^^^^ Per tmux(1), there ...
10
votes
2answers
2k views

Why pwd does not accept long options like --physical?

When I display the manual for pwd command, it says that long options like --physical are supported $ man pwd PWD(1) User Commands PWD(1) NAME ...
1
vote
1answer
57 views

Remove all lines that contain $PWD

I have a file that contains paths - looks like this: /Users/a/Desktop /Users/a/Documents /Users/a/Documents/Work What would be the easiest way to remove all lines that contain the current directory (...
0
votes
1answer
53 views

Trying to remove current directory using rmdir

I created a directory dir at Desktop and then i keyed in cd dir so as to make dir as my current directory and then i typed in the terminal rmdir /home/user_name/Desktop/dir from the dir directory ...
-4
votes
1answer
73 views

Linux: How to display the output of both command who and pwd using 1 command [closed]

I tried: who & pwd and it output the result of pwd output: /root. May I know if I am right?
1
vote
2answers
35 views

Get container directory more easily

I have a bash script here: $GOPATH/ src/ build.sh and in build.sh I have: export GOPATH="$(cd $(dirname "$BASH_SOURCE") && pwd)" is there a shorter way to get the containing dir ...
-2
votes
1answer
52 views

A directory showing up in itself [closed]

I do cd ~ and then pwd. It shows /root. Then I do ls. It again shows root. This is NOT another directory with the same name because when I do cd root, it says -bash: cd: root: Not a directory. ...
0
votes
2answers
76 views

content from pwd and which failed with sed to be replaced [duplicate]

I have a file which has the following content: BWA='/software/bwa/bwa-0.7.12/bwa' SAMTOOLS='/software/samtools/samtools-1.3.1/samtools' The above tools are on my computer: which bwa => /work/...
1
vote
1answer
450 views

How to change working directory of a child process by posix_spawn? [closed]

In Linux (CentOS 7.5, kernel 3.10, gcc 7.3), is it possible to change the working directory of a child process created by posix_spawn before it runs a given process image (an executable)? If yes, how? ...
2
votes
2answers
503 views

how to run shell command inside awk

i am trying to change dir when from A path to B path like below pwd|awk '{if($1=="/") cd /tmp/}' awk: syntax error near line 1 awk: illegal statement near line 1 please suggest
2
votes
3answers
668 views

why piping pwd and echo does not work? [duplicate]

I'm new to unix. I typed this command in ubuntu terminal: pwd | echo I expected to see the output of pwd in terminal(/home/fatemeh/Documents/Code/test) but the output was just a single empty line. ...
0
votes
0answers
175 views

sudo start login shell (-i) and stay at current working directory

When I login to root via sudo -i sudo changes the working directory of new shell to root's home directory. I can use following commands to keep working directory of parent shell: sudo -s sudo su ......
1
vote
1answer
209 views

Change path directory bash.exe

I installed bash on my Windows machine, and now when I run the shell, the pwd is: /mnt/c/Windows/System32 How may I change this? I open this shell everyday to work, and the directory when I'm ...
2
votes
1answer
298 views

What happens when the current directory is deleted?

In the first terminal A, I create a directory, enter the directory, and create a file: $ mkdir test $ cd test $ touch file1.txt $ ls file1.txt Then in another terminal B, I delete the directory: $ ...
-3
votes
2answers
36 views

In what cases may some programs require you to run them on a specific directory? [closed]

https://unix.stackexchange.com/a/76641/674 Create a short shell script to run your wine program in this directory, i.e. ~/bin/textaloud: #!/bin/bash cd "~/.wine/drive_c" exec wine "~/.wine/...
0
votes
2answers
729 views

Concatenate pwd and basename [closed]

I want to assign the path and file name to a variable: /path/to/myfile/file.txt For example MYFILE=$(pwd)$(basename) How can i do it ?
0
votes
1answer
198 views

How to make my PS1 bash session show the whole pwd at all times?

Relevant .bashrc section: if [ "$color_prompt" = yes ]; then if [[ ${EUID} == 0 ]] ; then PS1='${debian_chroot:+($debian_chroot)}\[\033[01;31m\]\h\[\033[01;34m\] \W \$\[\033[00m\] ' ...
29
votes
3answers
3k views

How does Unix keep track of a user's working directory when navigating the file system?

Say I log into a shell on a unix system and begin tapping away commands. I initially begin in my user's home directory ~. I might from there cd down to the directory Documents. The command to change ...
1
vote
3answers
1k views

How to get pid number and folder where it works

How I can get PID number and folder where it works? If I run 2 same programs in different folders: /var/www/public_html/first_folder/test.jar <i>(it runs all the time)</i> /var/www/...
9
votes
1answer
374 views

Etymology of $PWD

What is the etymology of $PWD? Is it an acronym? I know there is a command pwd which prints working directory, but to my mind, it would have made more sense to name the variable $CWD for Current ...
2
votes
1answer
180 views

pwd to return current path with “/” at the end

I want pwd to return /path/to/dir in the format /path/to/dir/ with the "/" at the end. Any ideas as to how I can accomplish this?
2
votes
1answer
64 views

How to find and print specific file paths with exclusions?

Goal: Output .txt file with the full directory path, including name, of all .html files except for those with "txt" or "text" in the .html file name. I found the following line gives me the desired ....
2
votes
2answers
263 views

How/where does the shell store environment variables?

So there's $PWD, $PATH, $USERNAME and all that. I've been working on my own shell and I've just today introduced environment variables. The way I'm doing it is by creating strings called pwd, path and ...
0
votes
1answer
513 views

calling $PWD from another script

Having some trouble getting $PWD to work inside a bash script... I have two scripts in the same directory: ~/outer.sh, ~/inner.sh. I use outer.sh to call inner.sh as follows: (outer.sh contents ...
1
vote
1answer
134 views

How can I set zsh to use physical paths?

In bash, I can put set -P in my .bashrc, and to use absolute paths. That is, if I change to a directory through a symbolic link, and then use cd .., it takes me to that directory's canonical parent, ...
0
votes
1answer
254 views

Parameters in bash $PS1 variable

Between the various parameters that can be included in the bash PS1 variable, \w expands the current working directory, with $HOME abbreviated with a tilde (uses the value of the PROMPT_DIRTRIM ...
1
vote
0answers
32 views

iterm syncing sessions across new tabs

When I open up new tabs in iterm and change a directory, it syncs the old tabs to that new directory. I don't want this behavior. I'd like it to preserve the session that it was on. What's the problem ...
-1
votes
4answers
2k views

Is there a difference between pwd and cd?

Is there a difference between pwd and cd (no arguments)? They both print the current directory's path but is there a subtle difference that I'm missing, and if so, when should I use which?
1
vote
1answer
440 views

moving subdirectories with the mv command

In the following structure, with a parent directory K and three subdirectories, D, H, and B, respectively, directly under it, my current directory is D. From there I need to move H as a subdirectory ...
1
vote
2answers
76 views

How to search string references in specified location?

I'm trying to find the occurrence of elements list(from a text file) in a directory. Below is the bash code I'm using, but I'm unable to get the output of grep command on to console. #!/bin/bash ...
17
votes
3answers
5k views

PS1='$(pwd)' why this works and why is this different from PS1=$(pwd)

Why when I enter this command the prompt changes to my directory? PS1='$(pwd)' I am using single quotes, which means no interpolation , a.k.a echo '$(pwd)' ——→ $(pwd) Furthermore, say that we ...
0
votes
0answers
654 views

Change env variable based off current directory - hook into cd command somehow? [duplicate]

Is there a way on *nix machines, to change the value of an environment variable depending on the current working directory? I am working on an NPM/Node.js module. Basically what I want to do, is ...
0
votes
1answer
26 views

launch a script which requires to be launched from a specific path via crontab

I have a script which before being launched checks via pwd if the path upon launch is something specific (say dir/subdir/script) current_folder=$(pwd | grep dir/subdir/script) if [ "$current_folder" =...
33
votes
4answers
4k views

How to tell if I'm actually in a symlink location from command line?

Suppose I have a folder: cd /home/cpm135/public_html and make a symbolic link ln -s /var/lib/class . Later, I'm in that directory: cd /home/cpm135/public_html/class The pwd is going to tell me I'...
2
votes
1answer
104 views

Why does the pwd doesn't update after directory removal?

I tried a little experiment where I created 2 folders Dir1 and Dir2 inside my Desktop directory, such that Dir1 is parent of Dir2. /home/username/Desktop/Dir1/Dir2 Then, I use cd to set my pwd as /...
2
votes
1answer
103 views

How can I make pwd resolve a soft link?

On one of our servers, we have a directory with the following path: "/daten/i/scripts" When you go to /daten/i, one can see that scripts is a soft link to "/batch". When I type cd /daten/i/scripts ...
3
votes
3answers
2k views

Create history log per working directory in bash

I was wondering if it is possible to keep a file containing history per current working directory. So for example if I was working in /user/temp/1/ and typed a few commands, these commands would be ...
1
vote
3answers
1k views

Alias for “cd” which shows current directory each time I change directories?

In tcsh, I would like an alias to pwd after I cd to a different directory. Previously I used the below alias for this, but it also changes the shell prompt to be [current directory]>. Due to ...
0
votes
2answers
218 views

colorized path in PS1

I'm trying to display path in colors but I have problem with this. I have some constant path - in variable MyPath. I want to create colorized path in PS1 but if pwd showing different path then my (...
5
votes
2answers
2k views

“ls $PWD” and “ls .” get different files, strange caching perhaps?

I have a strange problem on my Linux Mint machine (with solid-state drive if that matters). Somehow the machine (on multiple occasions) gets different files, and different content for the same file, ...
0
votes
2answers
327 views

mv .. with path: Where does my file go?

I have been using *nix systems for a while now, and I was surprised to see this situation in which mv misplaces or deletes my file. For example, I had a file foo.txt in the directory called ...
3
votes
2answers
665 views

How to Find out a GNU Screen Window’s Default Directory?

Question How do I find out the default directory of a window in GNU screen? NB: I’m not looking for the current directory of the process running in the window. Background I have created a hardcopy ...
1
vote
1answer
259 views

How to open a new terminal from my working folder in Solaris 10?

In Solaris 8, I could to ctrl+t to open a terminal from the file manager. But in Solaris 10, I can't seem to be able to. I try to create a shortcut key by gnome-terminal, but the pwd is always my ...