BASH commands
Hi there,
Im learning Bash on Red Hat Linux at the moment using a few books and the manual. Im getting some behavious that I dont really understand from some of the commands, and reading the manual hasnt helped at all, I was hoping someone could explain what was going on.
First off, I''m trying to delete a directory that contains a number of files and other directories with the following command:
rmdir /home/jon/stuff
I get a warning/error saying that the directory is not empty. I KNOW this, but dont want to have to go into all the sub-directories and delete them all. So after reading the manual I try:
$rmdir --ignore-fail-on-non-empty /home/jon/stuff
These seems to execute fine, but then when I try ''ls'' to check its been deleted then I find that ''stuff'' is still there; nothing happened. So I assume the switch just doesnt print the error message, rather than forcing the deletion? The manual isnt that clear.
I''m also having problems using the ''cp'' command to copy a directory (containing files and directories) from /mnt/cdrom to /home/jon/files - I just want to copy the files on the CD to my home directory, but I get a..
>omitting directory blah blah
..message and nothing is copied. I think I might have to use the -r switch with the command, but again, the manual isnt that clear on the subject.
Jon
Check the -R (recursive) option for 'rm' and 'cp'.
[edited by - rotos on December 20, 2003 1:26:35 PM]
[edited by - rotos on December 20, 2003 1:26:35 PM]
try
rm -rf
for removing directories.
And if you want you can add
alias rmdir="rm -rf"
to your ~/.profile or
~/.bash_profile
and type:
source ~/.profile or
source ~/.bash_profile
as for 'cp', the option for
recursive copying is
-r or -R. Do cp --help or
rm --help to figure
out parameters for
the commands.
[edited by - vboyx on December 20, 2003 1:31:07 PM]
rm -rf
for removing directories.
And if you want you can add
alias rmdir="rm -rf"
to your ~/.profile or
~/.bash_profile
and type:
source ~/.profile or
source ~/.bash_profile
as for 'cp', the option for
recursive copying is
-r or -R. Do cp --help or
rm --help to figure
out parameters for
the commands.
[edited by - vboyx on December 20, 2003 1:31:07 PM]
Ways to get info about commands:
cp --help
man cp
info cp
(replacing cp with whatever command it is that your looking for).
Also, more general info at web sites like www.tldp.org, particularly this guide might help you with BASH. This is also nice.
The following statement is true. The previous statement is false.
Shameless promotion:
FreePop: The GPL Populous II clone.
cp --help
man cp
info cp
(replacing cp with whatever command it is that your looking for).
Also, more general info at web sites like www.tldp.org, particularly this guide might help you with BASH. This is also nice.
The following statement is true. The previous statement is false.
Shameless promotion:
FreePop: The GPL Populous II clone.
My stuff.Shameless promotion: FreePop: The GPL god-sim.
quote: Original post by vboyx
alias rmdir="rm -rf"
to your ~/.profile or
~/.bash_profile
Don't do this- this is really dangerous (and never ever ever do this as root). Its best to specify -rf when you want it so that you dont accidentally do a 'rmdir ~/' or a 'rmdir /' accidentally and wipe out your system (and probably your windows dual boot too if its mounted in linux)
--
Dustin
edit: doc already covered 'man' and 'info' so I will remove this part of my post
[edited by - thedustbustr on December 20, 2003 12:40:32 AM]
Thanks for the replies and links, I''ll give the stuff you suggested a shot.
Jon
Jon
OK. Using the following seemed to work just fine:
rm -r stuff
Where stuff is a directory containing other directories and files. I guess I was looking in the wrong place- I was trying to use rmdir. I didnt realise you used rm to remove both files and directories.
cp -r test test2
Seemed to work fine- copied the whole directory tree. Thanks for telling me about the --help option.
Jon
rm -r stuff
Where stuff is a directory containing other directories and files. I guess I was looking in the wrong place- I was trying to use rmdir. I didnt realise you used rm to remove both files and directories.
cp -r test test2
Seemed to work fine- copied the whole directory tree. Thanks for telling me about the --help option.
Jon
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement