rm -rf /some/path/*
删除该目录(和子目录)中的所有非隐藏文件。
rm -rf /some/path/.*
删除该目录(但不是子目录)中的所有隐藏文件,并给出以下错误/警告:
rm: cannot remove directory: `/some/dir/.'
rm: cannot remove directory: `/some/dir/..'
Run Code Online (Sandbox Code Playgroud)
在目标目录中递归删除所有隐藏和非隐藏文件和文件夹而不收到关于.
and的警告/错误的正确方法是什么..
?
一个非常简单的小程序的可执行文件,比如下面显示的,在一种 Linux 上编译的,它会在不同的 Linux 上运行吗?还是需要重新编译?
在这种情况下,机器架构重要吗?
int main()
{
return (99);
}
Run Code Online (Sandbox Code Playgroud) 我尝试通过 SSH 启动 Firefox,使用
ssh -X user@hostname
Run Code Online (Sandbox Code Playgroud)
进而
firefox -no-remote
Run Code Online (Sandbox Code Playgroud)
但它非常非常慢。
我怎样才能解决这个问题?是连接问题吗?
让我们看下面的两行,它们给了我们两个不同的结果。
p=$(cd ~ && pwd) ; echo $p
p=$(cd ~ | pwd) ; echo $p
Run Code Online (Sandbox Code Playgroud)
两者有何不同?
我想删除文件中每行的第 5 个单词。
文件的当前内容:
File is not updated or and will be removed
System will shut down f within 10 seconds
Please save your work 55 or copy to other location
Kindly cooperate with us D
Run Code Online (Sandbox Code Playgroud)
预期输出:
File is not updated and will be removed
System will shut down within 10 seconds
Please save your work or copy to other location
Kindly cooperate with us
Run Code Online (Sandbox Code Playgroud) 在早期版本的 Unix 中,进程如何共享内存?这与共享内存的现代实现相比如何?
我有一个名为 的 MySQL 数据库camera_main_live
,我使用Adminer管理它。从表面上看,它是空的。因此,当我想添加一些内容时,我首先运行此脚本(将 Adminer 设置为出错时停止):
DROP TABLE IF EXISTS `Addresses`;
CREATE TABLE `Addresses` (
`Id` int(10) unsigned NOT NULL AUTO_INCREMENT,
`UserId` int(10) unsigned NOT NULL,
`FirstName` char(30) COLLATE utf8_unicode_ci DEFAULT NULL,
`LastName` char(30) COLLATE utf8_unicode_ci DEFAULT NULL,
`Address` char(30) COLLATE utf8_unicode_ci DEFAULT NULL,
`Street` char(30) COLLATE utf8_unicode_ci DEFAULT NULL,
`Town` char(30) COLLATE utf8_unicode_ci DEFAULT NULL,
`State` char(30) COLLATE utf8_unicode_ci DEFAULT NULL,
`Code` char(30) COLLATE utf8_unicode_ci DEFAULT NULL,
`Country` char(50) COLLATE utf8_unicode_ci DEFAULT 'Ireland', …
Run Code Online (Sandbox Code Playgroud) 我的一个文件夹包含以下格式的文件:
3_20150412104422154033.txt
3_2015041211022775012.txt
3_20150412160410171639.txt
3_20150412160815638933.txt
3_20150413161046573097.txt
3_20150413161818852312.txt
3_20150413163054600311.txt
3_20150413163514489159.txt
3_2015041321292659391.txt
3_20150414124528747462.txt
3_20150414125110440425.txt
3_20150414134437706174.txt
3_20150415085045179056.txt
3_20150415100637970281.txt
3_20150415101749513872.txt
Run Code Online (Sandbox Code Playgroud)
我想检索日期值小于或等于我的输入日期值的那些文件。
例如,如果我给出“3_20150414”即(3_YYYYMMDD),我希望输出是文件名
3_20150412104422154033.txt
3_2015041211022775012.txt
3_20150412160410171639.txt
3_20150412160815638933.txt
3_20150413161046573097.txt
3_20150413161818852312.txt
3_20150413163054600311.txt
3_20150413163514489159.txt
3_2015041321292659391.txt
3_20150414124528747462.txt
3_20150414125110440425.txt
3_20150414134437706174.txt
Run Code Online (Sandbox Code Playgroud)
我可以通过发出这样的命令来列出文件:
ls -l | grep '20150413\|20150414' |awk '{print $NF}'
Run Code Online (Sandbox Code Playgroud)
但我正在努力寻找<=
匹配。
我的桌面是Ubuntu,它有一个方便的程序notify-send
,它会在桌面上弹出一个警报。它还内置了以下方便的别名:
$ type alert\nalert is aliased to `notify-send --urgency=low -i "$([ $? = 0 ] && echo terminal || echo error)" "$(history|tail -n1|sed -e \'s/^\\s*[0-9]\\+\\s*//;s/[;&|]\\s*alert$//\')"\'\n
Run Code Online (Sandbox Code Playgroud)\n\n这意味着您可以运行very-long-running-command; alert
,让终端在后台运行,并在任务完成时收到通知。
当你通过 ssh 连接到 CentOS 服务器时,事情会有点棘手。这里\xe2\x80\x99是一种方法:
\n\nlocalhost$ ssh me@example.net; alert\nexample.net$ very-long-running-command; exit\n
Run Code Online (Sandbox Code Playgroud)\n\n这在某种程度上是有效的,但在每个命令后退出通常不是我想要做的。
\n\n我的电脑没有\xe2\x80\x99t 有扬声器。它可以发出蜂鸣声。
\n比较以下两个命令:
mysqldump database_name --hex-blob -uuser_name -p | tee database_name_tee.sql
mysqldump database_name --hex-blob -uuser_name -p > database_name_out.sql
Run Code Online (Sandbox Code Playgroud)
如果我运行第一个,完成后我会在终端上看到以下内容:
$ 62;c62;c62;c62;c
Run Code Online (Sandbox Code Playgroud)
这是从哪里来的?这是否表明过程中某处出了问题?这些控制字符是出于某种原因输出的吗?
U+0C62是泰卢固语元音符号 Vocalic L,我很确定这不是我的数据的一部分,所以我认为这不是 Unicode。无论如何,序列似乎不是c62
但是62;c
。这可能是某种控制字符。任何导致它的原因都包含在输出文件中。如果我稍后cat
要么database_name_tee.sql
或database_name_out.sql
,一旦cat
完成,我将再次看到此序列。
tail database.sql -n200
不产生这个输出;-n300
只产生$ 62;c62;c
; 并-n400
产生$ 62;c62;c62;c62;c
. 因此,导致这种情况的原因分布在整个文件中。
用head
和乱搞tail
,我发现了一个罪魁祸首:一行,当保存到一个单独的文件并用 打印时cat
,会产生$ 62;c62;c
. 我的问题是这一行是 1043108 字节。
(生成的 SQL 文件非常好,并且运行没有错误。我认为这与 MySQL 本身没有任何关系。)
我在mysqldump
CentOS 服务器上运行初始版本,并且cat
在服务器本身和我的 Ubuntu 桌面上看到了相同的效果,所以这似乎是一个通用的 …