Skip to main content

Questions tagged [pwd]

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

Filter by
Sorted by
Tagged with
0 votes
1 answer
43 views

Open a new window in tmux only if no window is opened in the given path, otherwise attach to it

Currently I have my terminal (alacritty) run tmux new -A -s 0 at start to start a new session 0, or attach to it if it already exists. One problem is, I sometimes use open in directory from file ...
MathIsNice1729's user avatar
0 votes
1 answer
78 views

Can I reprogram the pwd command to add a trailing slash?

WHen I use the pwd command, it prints e.g /opt instead of /opt/. I would like it to print the trailing slash. However, I tried adding the following line to my ~/.bash_aliases file: alias pwd=" ...
K.defaoite's user avatar
3 votes
1 answer
319 views

Interactive bash shell: Set working directory via commandline options

The short question is: I need to launch an interactive bash in a certain directory, and I can craft the command that launches bash, but I can't modify the system. At the moment, the command that best ...
user208769's user avatar
32 votes
1 answer
3k views

How to get the cd shell-builtin to stop guessing?

For example: $ ls -aF ./ ../ bin/ $ cd tin # with a tee, not bee bin $ pwd /home/user/bin In other words, cd guesses that what I really meant was cd bin, and successfully (huh?) changes the current ...
Ana Nimbus's user avatar
0 votes
1 answer
216 views

pwd add '\' in folder spaces

i know that on Linux when you try to cd with folder that have spaces you must add \ in there. for example, i have folder named folder one. when i try pwd the output is : /home/user/folder one what i ...
Tzy's user avatar
  • 1
1 vote
1 answer
70 views

Enter directory without knowing its name?

Suppose we have a user pepe who has a directory ~/pepe_cant_see in his home directory in which he possesses -wx permissions, and inside of this directory, another directory ~/pepe_cant_see/...
Franklin Pezzuti Dyer's user avatar
15 votes
1 answer
3k views

Why did 'scp 10.0.0.11:/home/someuser/.*' start copying from /home as well?

I'm doing my first ever moving of user files from an old system to a new system. My goal is to use SCP for it's simple syntax of scp -r source destination. I tried the following command to copy the ...
Brian's user avatar
  • 292
7 votes
1 answer
10k views

What is the difference between cwd and pwd?

What is the difference between cwd and pwd? I've tried googling it, and one of the answers mentioned that depending on some factor (which I sadly do not remember), the implementation (the code I'm ...
account's user avatar
  • 73
0 votes
4 answers
1k views

How Can I Use the sed Command to Replace /home/user With ~

Suppose this is the output of pwd: /home/amarakon/.local/src/amarakon/scripts/src How can I change it to this: ~/.local/src/amarakon/scripts/src I tried this command: pwd | sed 's|/home/.*|~|' But ...
Amarakon's user avatar
  • 333
1 vote
1 answer
483 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
Fluffy's user avatar
  • 7
2 votes
2 answers
749 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....
Lonnie Best's user avatar
  • 5,165
0 votes
1 answer
42 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 ...
echo_LOGNAME's user avatar
1 vote
1 answer
173 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 ...
Daniel Imms's user avatar
4 votes
2 answers
5k 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 ...
Lucretiel's user avatar
  • 212
0 votes
1 answer
1k 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 ...
computational's user avatar
0 votes
0 answers
229 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. ...
gatorback's user avatar
  • 1,384
0 votes
1 answer
191 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 (/...
noraj's user avatar
  • 340
4 votes
1 answer
854 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 . ...
dukeluke's user avatar
  • 141
0 votes
1 answer
449 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?
Stanley Hughes's user avatar
0 votes
1 answer
1k 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] ...
Nick Bailuc's user avatar
0 votes
0 answers
70 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 ...
retnikt's user avatar
  • 319
0 votes
1 answer
1k 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. ...
Al_'s user avatar
  • 101
0 votes
0 answers
259 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 ...
Saxpy's user avatar
  • 11
1 vote
1 answer
37 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' ......
Justin's user avatar
  • 11
2 votes
2 answers
518 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 ...
simhumileco's user avatar
1 vote
2 answers
123 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 > ...
Robert Fleming's user avatar
4 votes
1 answer
310 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 ...
Gilles 'SO- stop being evil''s user avatar
0 votes
1 answer
869 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 ...
Proteeti Prova's user avatar
0 votes
1 answer
133 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/...
gwrathe's user avatar
1 vote
0 answers
47 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?
l00p's user avatar
  • 263
1 vote
1 answer
1k 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 ...
John's user avatar
  • 113
1 vote
1 answer
8k 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 ...
somethingSomething's user avatar
0 votes
2 answers
5k 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 &&...
Arefe's user avatar
  • 233
1 vote
1 answer
3k 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> [email protected]:~/<dirname of toplevel> In other words, I'm trying to copy the current directory I'm in locally (and the ...
Brandon J's user avatar
1 vote
2 answers
1k 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 ...
iBug's user avatar
  • 3,548
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 ...
Michal Kordas's user avatar
1 vote
1 answer
88 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 (...
Emanuil Rusev's user avatar
0 votes
1 answer
2k 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 ...
LocalHost's user avatar
  • 499
-4 votes
1 answer
439 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?
gene's user avatar
  • 11
1 vote
2 answers
132 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 ...
Alexander Mills's user avatar
-2 votes
1 answer
69 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. ...
a_fan's user avatar
  • 115
0 votes
2 answers
447 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/...
user977828's user avatar
2 votes
1 answer
2k 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? ...
user1507435's user avatar
3 votes
2 answers
8k 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
Anavarathan's user avatar
6 votes
3 answers
7k 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. ...
Fatemeh Karimi's user avatar
1 vote
1 answer
763 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 ...
user avatar
8 votes
2 answers
3k 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: $ ...
wenzeslaus's user avatar
-3 votes
2 answers
113 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/...
Tim's user avatar
  • 103k
3 votes
2 answers
13k 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 ?
Omar BISTAMI's user avatar
1 vote
1 answer
638 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\] ' ...
Vlastimil Burián's user avatar