内置命令和另一个名义上可以做同样事情的命令之间有什么内在的区别吗?
例如。内置函数是否得到“特殊”处理?...运行它们的开销是否更少?.. 或者它们只是简单地“内置”;像你汽车的仪表盘?
...是否有这些内置函数的明确(当前)列表?
$ tail -f testfile
Run Code Online (Sandbox Code Playgroud)
该命令应该实时显示指定文件中的最新条目,对吗?但事实并非如此。请纠正我,如果我打算做的事情是错误的......
我创建了一个新文件“aaa”并添加了一行文本并将其关闭。然后发出这个命令(第一行):
$ tail -f aaa
xxx
xxa
axx
Run Code Online (Sandbox Code Playgroud)
最后三行是文件aaa的内容。现在命令仍在运行(因为我使用了-f),我通过 GUI 打开文件 aaa 并开始手动添加更多行。但是终端不显示文件中添加的新行。
这里有什么问题?tail -f如果新条目仅由系统写入,该命令仅显示新条目?(如日志文件等)
有没有办法head/tail一个文件并获得反向输出;因为您不知道文档中有多少行?
即我只想获取除前两行之外的所有内容foo.txt以附加到另一个文档。
字母使用单破折号和单词使用双破折号的惯例从何而来,为什么继续使用?
例如,如果我输入ls --help,您会看到:
-a, --all do not ignore entries starting with .
-A, --almost-all do not list implied . and ..
--author with -l, print the author of each file
-b, --escape print octal escapes for nongraphic characters
--block-size=SIZE use SIZE-byte blocks
-B, --ignore-backups do not list implied entries ending with ~
...
Run Code Online (Sandbox Code Playgroud)
我尝试使用谷歌搜索- and -- convention即使没有成功的报价。
我想将某个父目录中所有文件和子目录的组权限设置为该特定文件或目录的用户权限设置。
例如,下面的所有内容 /path/to/parentdir
# Permissions before
# Path Permissions
/path/to/parentdir/file1 755
/path/to/parentdir/file2 644
/path/to/parentdir/file3 600
# Permissions after
/path/to/parentdir/file1 775
/path/to/parentdir/file2 664
/path/to/parentdir/file3 660
Run Code Online (Sandbox Code Playgroud)
我希望有一种简单的方法可以在一个命令中做到这一点。我可以想到使用带有一堆命令的脚本的方法,但感觉应该有一种非常直接的方法。
提前致谢!
$ which echo
echo: shell built-in command.
$ which ls
/bin/ls
$ which cat
/bin/cat
Run Code Online (Sandbox Code Playgroud)
为什么回声不喜欢一个独立的工具ls,ps,cat等?为什么它是特定于外壳的?有什么好的理由吗?
我注意到这ls -l不仅改变了输出的格式,而且还改变了目录符号链接的处理方式:
> ls /rmn
biweekly.sh daily.sh logs ...
> ls -l /rmn
lrwxrwxrwx 1 root root 18 Feb 11 2011 /rmn -> /root/maintenance/
Run Code Online (Sandbox Code Playgroud)
我想获得 中内容的详细列表/rmn,而不是有关/rmn符号链接的信息。
我能想到的一种解决方法是创建一个执行以下操作的 shell 函数:
cd /rmn
ls -l
cd -
Run Code Online (Sandbox Code Playgroud)
但这似乎太老套了,尤其是因为它会弄乱cd -. 有没有更好的办法?
(我使用的是 CentOS 2.6.9)
我正在尝试git clone通过 bash 脚本执行一个低谷,但是我第一次运行脚本并且服务器未知时脚本失败。我有这样的事情:
yes | git clone git@github.com:repo/repoo.git
Run Code Online (Sandbox Code Playgroud)
yes | git clone git@github.com:repo/repoo.git
Run Code Online (Sandbox Code Playgroud)
但它忽略了yes. 您知道如何强制git clone将密钥添加到已知主机吗?
如果我不想手动下载在特定 url 路径中找到的文件,我有哪些选择?使用通配符失败:
$ wget 'http://www.shinken-monitoring.org/pub/debian/*deb'
Warning: wildcards not supported in HTTP.
....
Run Code Online (Sandbox Code Playgroud)
这当然假设我事先不知道文件名。
我有许多名为的 tiff 文件:
sw.001.tif
sw.002.tif
...
Run Code Online (Sandbox Code Playgroud)
我想删除.tif每个文件末尾的 。我怎样才能使用rename命令来做到这一点?