我有一个rm命令清除特定目录中的所有文件。
#!/usr/bin/ksh cd /asd/ded/ses/ddd/rty/leg/ rm *.sas7bdat rm p_bt*不幸的是它清除了这个目录下的所有文件,但是现在我只想在“父目录”中清除它,即“/ asd / ded / ses / ddd / rty / leg /”而不是“/ asd / ded / ses /” ddd / rty / leg / 21_11“这是它里面的子目录。
我知道在bash中可以使用rm级别。 KSH是否会改变,如果是,那么如何改变。
I have a rm command which clears all the files in a particular directory.
#!/usr/bin/ksh cd /asd/ded/ses/ddd/rty/leg/ rm *.sas7bdat rm p_bt*Unfortunately it clears all the files under this directory, but now I just want it to clear in "parent directory" i.e. "/asd/ded/ses/ddd/rty/leg/" and not in "/asd/ded/ses/ddd/rty/leg/21_11" which is the child directory inside it.
I know level rm is possible in bash. Does it change for KSH and if yes then how.
最满意答案
孤寂的灵魂,
切普纳是对的。 ksh中“rm”的默认设置是仅删除当前目录中的文件。 您可以通过添加'-r'选项从下层目录中删除文件(递归)。
如果您正在观察不同的行为,则可能在配置文件中的某处设置了别名设置。 尝试输入'whence rm'以查看是否存在导致意外行为的别名。
例子。
>pwd /tmp >touch abc.txt >mkdir ced >touch ced/abc.txt >rm abc.txt (will remove abc.txt in /tmp, but leave the file in directory ced. >whence rm rm -fLonelySoul,
Chepner is correct. The default for 'rm' in ksh is to only remove the files in the current directory. You can remove files from the lower directories (recursively) by adding the '-r' option.
If you are observing different behavior, you may have an alias setup somewhere in your profile. Try entering 'whence rm' to see if there is an alias that is causing you unexpected behavior.
Examples.
>pwd /tmp >touch abc.txt >mkdir ced >touch ced/abc.txt >rm abc.txt (will remove abc.txt in /tmp, but leave the file in directory ced. >whence rm rm -f更多推荐
发布评论