I'm new using the linux commands and I'm having a problem using the rm command in a makefile.
The makefile is in the /project directory and I want to remove all the files with extension .o that are in the /project/src folder.
I have tried with
rm /src/ -f *.o
and
rm /src -f *.o
I do not receive any error in the console but it does not delete the files either.
Could someone please help me?
Thanks for your time!
You can delete files like this
rm -f src/*.o
-f is to force deletion, without confirmation
You can use: rm -f /projects/src/*.o
Related
Linux os
Hello
i have downloaded the file using wget. the file downloaded with some messy name like
index.html?format=csv&timezone=Asia%2FKolkata&use_labels_for_header=true.
now i am trying to remove this file using rm, but its not getting removed.
Linux os
sudo rm -f Unconfirmed\sudo rm -f Unconfirmed\index.html?format=csv&timezone=Asia%2FKolkata&use_labels_for_header=true
how can i removed it from folder.
It works as below. Make sure you have permission for that file/folder to edit(delete or update). You have used sudo that is correct.
To remove the folder with all its contents(including all interior
folders):
rm -rf /path/to/directory
To remove all the contents of the folder(including all interior folders) but not the folder itself:
rm -rf /path/to/directory/* or
rm -rf /path/to/directory/{*,.*}
if you want to make sure that hidden files/directories are also removed.
To remove all the "files" from inside a folder(not removing interior folders):
rm -f /path/to/directory/{*,.*}
Where:
rm - stands for "remove"
-f - stands for "force" which is helpful when you don't want to be asked/prompted
if you want to remove an archive, for example.
-r - stands for "recursive" which means that you want to go
recursively down every folder and remove everything.
rm -rf "yourfilename" put double quotes over your file name.
Also check if you have permission to delete this file.
make notifies you of the deletion by printing an rm -f command that specifies the file it is deleting.
Eg:
Here MergeSort is the file that I need to remove.
I have a folder which is:
/var/www/xxx/html/'.
It was created accidentally. I try to delete it but it comes up,
No such files or directory
I have tired
rm -f /var/www/xxx/html/'.
rm -f "/var/www/xxx/html/'."
rm -f /var/www/xxx/html/*'*.
It is because of the '.
I have been looking around for a few hours but no joy.
cd /var/www/xxx/html
rm -rf \'.
worked for me.
Try this :
rmdir /var/www/xxx/html/\'
Hi I just created a file by mistake, doing a tar actually, anyway the problem I have is that I can't remove that file. It is called --exclude-tag-under=hey.txt
I am trying to use rm -rf command but it doesn't do the trick. this is the output
[root]# rm -rf '--exclude-tag-under\=hey.txt'
rm: unrecognized option '--exclude-tag-under\=hey.txt'
Try 'rm --help' for more information.
the problem here is that the command rm is recognizing the file as a flag and thats a problem, I've tried also
rm -rf *hey.txt
but it doesnt work neither
I've also tried to change the name of the file but its the same problem
Prepend ./ like this: rm ./--exclude-tag-under\=hey.txt
When in doubt, check the man pages.
Running man rm will give you the rm man page, which, on Linux and OpenBSD (the ones I have tested) at least, will have a section saying:
To remove a file whose name starts with a '-', for example '-foo', use
one of these commands:
rm -- -foo
rm ./-foo
Use rm -- --exclude-tag-under=hey.txt
$ ls
--exclude-tag-under=hey.txt
test
$ rm -- --exclude-tag-under=hey.txt
$ ls
test
I am using zsh and I want to delete contents of a folder without deleting the folder itself. What is the best way to go about this?
rm -r myfolder/* will delete all files in that folder that do not begin with a dot.
Really the simplest solution is rm -rf myfolder && mkdir myfolder.
You can just use rm -r path/to/dir/*.
I'm working with a CentOS server. I have a folder named test located in /home/server/folder/test. I need to copy the directory test to /home/server/. How can I do it?
cp -r /home/server/folder/test /home/server/
To copy all files, including hidden files use:
cp -r /home/server/folder/test/. /home/server/
As I understand, you want to recursively copy test directory into /home/server/ path...
This can be done as:
-cp -rf /home/server/folder/test/* /home/server/
Hope this helps
This works for me.
cp -r /home/server/folder/test/. /home/server
For copy directory use following command
cp -r source Destination
For example
cp -r /home/hasan /opt
For copy file use command without -r
cp /home/file /home/hasan/