Questions tagged [pwd]
For questions about the working directory of processes, as well as the `pwd` command
99
questions
0
votes
0
answers
43
views
How to start game servers outside their directories? [closed]
I want to make a simple, easy game server control panel but I don't have an idea how those control panels are starting their game servers without copying the whole game's directory for starting the ...
1
vote
1
answer
30
views
Display recursively all parent directories relative to the current one
Display recursively all parent directories relative to the current one.
#!/bin/bash
IFS=/
for var in $(pwd)
do
echo "$var"
done
1
vote
1
answer
82
views
Get the Absolute Path from feh
The feh command allows you to view images within a folder recursively:
feh --recursive --auto-zoom
While viewing images, it also allows you to associate custom commands with keys 0-9 on your keyboard....
0
votes
1
answer
38
views
How to list contents my present directory but only show the absolute file path and name?
I have an alias:
alias lp=find $(pwd)
I would like this to be similar to ls and ll (list path) but this command searches through every directory instead of my present working directory.
I would ...
1
vote
1
answer
85
views
Get the unresolved pwd of a shell from another process
I'm hitting an issue where I need to get the unresolved symlink of a shell process. For example given a symlink ~/link -> ~/actual, if bash is launched with a $PWD of ~/link, I need to fetch that ...
3
votes
1
answer
1k
views
How to change the tmux working directory with a shell command
I want to create a shell command that, when run, sets the working directory of the current tmux session to the current working directory.
There are numerous answered questions on how to set the ...
1
vote
1
answer
547
views
Alias to copy current directory path to clipboard through ssh linux
I am working on macos and on the terminal app I am connecting to a server which run on linux, through ssh -X (and I actually I should not be allowed to install any software on it).
In order to save ...
0
votes
0
answers
53
views
return escape spaces with pwd
printf "%q\n" "$(pwd)"
zSH Catalina OSX returns
/Volumes/Public/Photos/Paris\ 2016/Musee\ Rodin\ 2016
I would like the result in a variable so that it can be used in a script. ...
0
votes
1
answer
91
views
Current/working directory issue from wrapper
A common packaging issue I encounter is when a tool is looking for relative resources in its root directory (install directory).
Eg. pkg-name (/usr/share/pkg-name/pkg-name) is looking for resourceA (/...
5
votes
1
answer
483
views
What does the '.' dot mean as a working directory?
I'm not referring to the . you see in shell commands or in the output of ls -a.
I just ran an install script for a vpn application, and after the command exited, my terminal prompt was in the . ...
0
votes
1
answer
286
views
What use rm -rf "`pwd`/folder instead of rm -rf ./folder [closed]
Why would I want to use the command
rm -rf "`pwd`/folder"
instead of
rm -rf ./folder
What reasons are there to prefer one over the other?
0
votes
1
answer
435
views
GNOME ".desktop" shortcut: Specify Start-In path
I'm making some shortcuts to games I would normally run via terminal. For instance,
UT2004:
cd "$HOME/Unreal Tournament 2004/System/"
./ut2004-bin-linux-amd64
My work so far:
[Desktop Entry]
...
0
votes
0
answers
24
views
How does my shell know when the current working directory has been moved?
If I am in a directory /foo, and I move (from a different session) /foo to /bar. If I then go back to the session in /foo and run ls, the files are still there, and I can see new files if they are ...
0
votes
1
answer
478
views
Can't loop files using pwd if current directory has spaces in the path [duplicate]
I have the following bit of code in a bash script I've created. When I run it from a directory with no spaces in the path it works as expected, however if I run from a directory with spaces it fails. ...
0
votes
0
answers
117
views
Subshell does not inherit PWD
Hi I am fairly new to Linux and I've been trying to SSH and CD in one line from Windows 10 into Ubuntu. One solution I thought to try was:
ssh -t <ip address> "cd <directory>; bash"
I've ...
1
vote
1
answer
19
views
unbundling a file of here docs when file's directory is different from pwd
All,
I have a file (called, say, bundled_file.txt) of here docs stored in a directory, and the file looks like this:
cat > a.txt << 'eof'
...
...
...
'eof'
cat > b.txt << 'eof'
......
1
vote
2
answers
44
views
How to change user and keep current location?
I wonder how in one command I can switch to another user (in my case it is usually root) and still remain in the same location where I am before the change.
I usually do it this way, unfortunately ...
1
vote
2
answers
90
views
sh: is there a command to interactively edit the PWD?
I'm looking for a command that invokes readline or similar, primed with the current $PWD, to let the user edit the current directory, then cd to the edited value. E.g.
> cd ~/a/b/c/d
> pwd
> ...
4
votes
1
answer
197
views
Complete a command fully relative to a different directory
I have a function to run a single command in a different category. cd1 SOMEDIR MYCOMMAND ARG… is equivalent to (cd SOMEDIR && MYCOMMAND ARG…), with two advantages. It's slightly easier to type ...
0
votes
1
answer
480
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
1
answer
87
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
0
answers
44
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?
1
vote
1
answer
505
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 ...
1
vote
1
answer
4k
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
2
answers
3k
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 &&...
1
vote
1
answer
2k
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
2
answers
746
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 ...
12
votes
2
answers
3k
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
1
answer
81
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
1
answer
886
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
1
answer
301
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
2
answers
73
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
1
answer
56
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
2
answers
398
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/...
2
votes
1
answer
1k
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? ...
3
votes
2
answers
5k
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
3
votes
3
answers
4k
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.
...
1
vote
1
answer
659
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 ...
7
votes
2
answers
2k
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
2
answers
44
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/...
1
vote
2
answers
8k
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 ?
1
vote
1
answer
442
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\] '
...
30
votes
3
answers
4k
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 ...
3
votes
3
answers
5k
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
1
answer
647
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
1
answer
436
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
1
answer
199
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
2
answers
309
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 ...
1
vote
1
answer
1k
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 ...
2
votes
1
answer
428
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, ...