linux copy symbolic link [closed] - linux

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about programming within the scope defined in the help center.
Closed 9 years ago.
Improve this question
How do I copy a symbolic link from one directory to another?
ls -ls
file1.txt
file2.txt
files -> /mnt/iscsi-nfs-share/faulttracker-files
what I'm looking to do is copy files symbolic link into another directory?
cp files /var/copylinktohere/
the above results in
cp: omitting directory `files'

Use the -d option:
cp -d files /var/copylinktohere/
From man cp:
-d same as --no-dereference --preserve=link
--no-dereference
never follow symbolic links

Related

mktemp -d not creating temp directory [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about programming within the scope defined in the help center.
Closed 2 months ago.
Improve this question
I am trying to create a temporary directory using mktemp -d but it is not creating a directory. When I try to run cd $(mktemp -d) it takes me to my home folder. This behavior is similar to cd .
When I try to run mktemp -d and check the exit code using echo $? it return 248 as the exit code.
What is going on?
Most likely $(TMPDIR) is set to a non-existent directory or one to which your user lacks write+execute permissions.

mv cannot stat '*.txt' : No such file or directory [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 11 months ago.
Improve this question
Be nice. I'm learning Linux and can't find this answer (I've searched)
I'm trying to move all the .txt files in Folder1 to my Documents directory.
~$ ls
Desktop Documents Downloads file1.txt Music Public Templates test user0files.txt user-files.txt Videos
~$ cd ~/Documents
~/Documents$ ls
Folder1 Folder2 test1.txt test2.txt
~/Documents$ cd ~/Documents/Folder1
~/Documents/Folder1$ ls
bale.txt, ball.txt, bowl.txt, foldernew
~/Documents/Folder1$ mv *.txt ~/Documents
mv: cannot stat '*.txt': No such file or directory
From here I tried moving foldernew by name to ~/Documents and it worked. Can someone explain what I am doing incorrectly?
Thanks so much!!
It looks like you have a bunch of files that end in .txt, (note the comma), so *.txt doesn't find them.
Rename the files to remove the comma and try again.

copy file from directory in directory stack to current directory [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about programming within the scope defined in the help center.
Closed 4 years ago.
Improve this question
I often find myself wanting to copy files from one of the directories in my directory stack to another, and the best solution I've come up with is cp $(dirs -p | tail -n 1)/somefile.txt ./somefile.txt
Is there a better solution for this?
You can access the directory stack directly via the DIRSTACK array; no command substitutions are needed.
cp "${DIRSTACK[-1]}/somefile.txt" .
Your original code was buggy for the same reason the output of ls should not be used programmatically; a directory name containing a newline character could break it. For example:
$ pushd $'foo\nbar'
$ dirs -p | head -1
~/bin/foo
Using dirs +0 at least fixes that problem (assuming you correctly quote the command substitution as cp "$(dirs +N)"/somefile.txt ./somefile.txt, anyway):
$ dirs +0
~/bin/foo
bar
After referncing the https://www.gnu.org/software/bash/manual/html_node/Directory-Stack-Builtins.html#Directory-Stack-Builtins, a slightly better solution is cp $(dirs +N)/somefile.txt ./somefile.txt

difference in outputs of pwd and /bin/pwd [closed]

Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 10 years ago.
Improve this question
i created a soft link from my home folder to /etc/ by using
"ln -s /etc/ foo"
then i changed directory to foo
"cd foo"
now i executed the following two commands
"pwd" and "/bin/pwd"
Both gave me different outputs.
The output of "pwd" was /home/myhome/foo and of "/bin/pwd" was /etc.
I am not able to understand the difference in the outputs although both commands are the same.
Possibly a bit oversimplified, but the bash builtin pwd tracks cd commands, so when you cd through a symbolic link, it remembers that. On the other hand, /bin/pwd walks the directory tree back to the root, and, as such, has no idea what symbolic links you might have walked through to get where you are.

How to create a link to a directory on linux [closed]

Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 10 years ago.
This post was edited and submitted for review last month and failed to reopen the post:
Original close reason(s) were not resolved
Improve this question
How to create a link to an existing file or directory using a GNU Linux shell command?
Symbolic or soft link (files or directories, more flexible and self documenting)
# Source Link
ln -s /home/jake/doc/test/2000/something /home/jake/xxx
Hard link (files only, less flexible and not self documenting)
# Source Link
ln /home/jake/doc/test/2000/something /home/jake/xxx
More information: man ln
/home/jake/xxx is like a new directory. To avoid "is not a directory: No such file or directory" error, as #trlkly comment, use relative path in the target, that is, using the example:
cd /home/jake/
ln -s /home/jake/doc/test/2000/something xxx
you should use :
ln -s /home/jake/doc/test/2000/something xxx

Resources