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.
Related
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 7 years ago.
Improve this question
I have websites folders in my /home directory of centos 7. i want to copy robot.txt and favicon.ico file in all websites directories.
Websites directory structure are as following:
/home/domain.com/public_html
/home/domain2.com/public_html
I want command which copy robot.txt and favicon in all websites public_html directory from /root/robots.txt and /root/favicon.ico and if file already available on the destination folder then the command will overwrite file.
Many Thanks
You can use find too.
find /home -type d -name public_html -exec cp /root/robots.txt /root/favicon.ico {} \;
Just use a simple for loop that processes each directory.
for dest in /home/domain*.com/public_html
do
cp /root/robots.txt /root/favicon.ico $dest
done
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 7 years ago.
Improve this question
Operating system: SLES12 VM
So I start off in a directory:
DirA: /home/user/testA/testB
My goal is to move a file from this directory to a directory given by
DirB_rel: /home/user/testA/testB/../../deliverables/rpm/SOURCE
Note: testA is a symlink which is not included in DirB_abs
Which, when I cd to it, gives a pwd of
DirB_abs:/home/user/deliverables/rpm/SOURCE
The problem is, when I try move a file using mv (have tried tar.gz and .txt) from DirA to DirB_rel, the file is deleted from original location as expected, but it does not appear at new location and is therefore lost.
E.g. mv testFile.txt DirB_rel -> File disappears
However, when I use the absolute path for directory B, mv works correctly.
E.g. mv testFile.txt DirB_abs -> Success
Any idea whats going on here?
Thanks!
The problem is with the symlink. When you do user/testA/testB/../../ and testA is asymlink, you wont go back to user, but to the parent directory of the directory testA links to
the mv command will reference the directory you are currently in and not from where the file is. So if we are in home ~/ and want to move ~/A/file to ~/B/file you use mv as follows:
mv A/file B/
Note that if you use this
mv A/file ../B/
the command will look for B in /home/B and not ~/B since we are in the ~/ directory issuing the command.
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 7 years ago.
Improve this question
I have a folder that contains many folders and my wordpresses sites.
At the same folder i need to catch up the "uploads" subfolder and tar it named by its site.
Can anyone help me out?
Does this do the trick?
find /var/www -name uploads -a -type d | awk -F '/' '{ system("tar -czvf "$3".tar "$0) }'
The find command lists all the directories named upload under /var/www.
That's piped to awk, which splits it using the slash and runs tar. The third field is used as the file name and the whole string as the target for the tar.
This works for me: tar -cvf thisstuff.tar */uploads/*
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 9 years ago.
Improve this question
What I'm doing is:
tar -czf etc.tar.gz /etc /usr/local/etc
And when I extract it I will have two directories:
1) etc
2) usr
What I want is to do it this way that I will have only etc after extracting with contents of this two directories.
Thanks.
Is there any other way than creating temporary directory with merged files from /etc and /usr/local/etc and then removing it?
cd /
tar -cf /path/to/etc.tar etc/
cd /usr/local
tar -rf /path/to/etc.tar etc/
cd /path/to
gzip etc.tar
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 8 years ago.
Improve this question
I have a directory /f/ssh which I would like to turn into /f/.ssh. I'm working with git-bash on win7 I've tried:
/f
$ mv /ssh /.ssh
mv: cannot stat `/ssh': No such file or directory
/f
$ mv ssh .ssh
mv: cannot move `ssh' to `.ssh/ssh'
But its not working. How can I make this happen ?
You probably want your second example (current working directory) and not root (/).
$ mv ssh .ssh
mv: cannot move `ssh' to `.ssh/ssh'
What this is saying is there is already a folder called ".ssh" in your current working directory.
By calling that command again it's also saying you don't have access to move "ssh" into the already existing ".ssh" folder.
Try an ls -al to list all current files/folders in the directory, including hidden.