我正在使用 Linux Mint。我的登录 shell ( cat /etc/passwd | grep myUserName
) 是 bash。
在我启动我的图形桌面环境并从中运行终端模拟器后,我可以看到它.bash_profile
没有来源(其中export
ed 的环境变量未设置)。但是,如果我从一个文本控制台登录(ctrl+ alt+ F1)或手动运行bash -l
从终端仿真器,.bash_profile
工作正常。
当我认为.bash_profile
应该在 X 启动时获取并且所有export
'ed vars 应该在终端中可用,从 X 运行时,我错了吗?
PS 将所有内容放入.bashrc
并从中采购.bash_profile
并不是一个好主意(/sf/ask/63206251/):环境的东西应该只采购一次。
bdiff(1)
Solaris 中有一个命令,它允许您处理diff(1)
大于 RAM 大小的文件(http://docs.oracle.com/cd/E19683-01/806-7612/files-23/index.html)。
Linux 中有类似的东西吗?我试过谷歌搜索,但我没有bdiff
在 Ubuntu 中找到哪个包。
我有一个安装了 FreeBSD 的 HDD(或 SSD 或闪存驱动器),不知何故我破坏了引导代码(MBR 的前 446 字节)。我怎么能启动到这个 FreeBSD?
我有这个错误
configure: error: GNU make is required!
Run Code Online (Sandbox Code Playgroud)
我不能变成 /usr/ports/devel/gmake/
$ cd /usr/ports/devel/gmake/
cd: /usr/ports/devel/gmake/: No such file or directory
Run Code Online (Sandbox Code Playgroud)
如何在 FreeBSD 10 上安装 GNU make?
sudoers(5)
手册页说可以在 sudoers 文件的命令行参数中使用 shell 样式的通配符(又名元或全局字符)。它们是*
,?
,[...]
和[!...]
。
我的想法是在正则表达式样式中使用一些东西,例如/path/to/command -a[v]*
, 表示command -a
,command -av
并且command -avvv...v
在一行中(对于这种根据-v
参数数量改变其详细程度的命令,例如tcpdump
)。但它不起作用。
有没有办法做到这一点,而不是在每个中添加不同数量的/path/to/command -a -v
多次?sudoers
-v
我正在尝试在我的 bash 脚本中执行一个字符串。字符串包含变量(因此我可以根据情况替换一些 CLI 参数)。
问题是当我使用变量 contains 时--argument=value
,一切都会崩溃,并给出错误:
Missing trailing-' in remote-shell command.
Run Code Online (Sandbox Code Playgroud)
示例代码:
#!/bin/bash
rsync_path="/usr/bin/rsync -azhrP"
rsync_ssh_cmd="--rsh='ssh -o Compression=no'"
`$rsync_path /path/to/file $rsync_ssh_cmd username@localhost:/tmp`
Run Code Online (Sandbox Code Playgroud)
如果我只是echo
此代码中的最后一个字符串,它看起来不错。但是如果我尝试从脚本执行这个字符串,它不会按预期执行。
我找到了一个解决方法 - 如果我尝试一切都会好起来的
eval "my-command-string"
Run Code Online (Sandbox Code Playgroud)
代替
`my-command-string`
Run Code Online (Sandbox Code Playgroud)
或者
(my-command-string)
Run Code Online (Sandbox Code Playgroud)
为什么会这样?我怎么能(我真的应该?)避免使用eval
?
我使用 bash 4.3.11(1)-release (x86_64-pc-linux-gnu)
(Kubuntu 14.04.3)。
我尝试了以下不同的变体,但似乎没有任何效果。基本上当find
被执行时似乎什么都没有发生。下面我展示了我的 bash 函数代码和运行时的输出。
我有兴趣了解下面的代码会发生什么,以及为什么它不像我明确键入命令时那样表现。
我还被告知我将无法访问rgrep
我将要处理的某些盒子,因此我尝试使用这种方法来获取代码等的通用解决方案。
function findin() {
if [ -z $1 ] ; then
echo "Usage: findin <file pattern> <<grep arguments>>"
return 1
fi
fIn[1]=$1
shift
fIn[2]="$@"
echo -- "${fIn[1]}"
echo -- "'${fIn[2]}'"
find -type f -name "'${fIn[1]}'" -print0 | xargs -0 grep --color=auto ${fIn[2]}
}
Run Code Online (Sandbox Code Playgroud)
输出是:
$ ls
Server.tcl Server.tcl~ test.cfg vimLearning.txt
$ find -type f -name '*.txt' -print0 | xargs -0 grep --color=auto char
x deletes char under cursor. NNx deletes NN chars …
Run Code Online (Sandbox Code Playgroud) 假设我有一些 CLI one-liner,它输出一些带有空格分隔部分的文本行。这些部分在逻辑上应该是列,但由于文本宽度,它看起来并非如此。
我如何自动格式化这样的输出以使其成为漂亮的列?
例如,我有类似的输出
Alice param1 param2345 32768 50 16
Bob param2345 param1 512 10 1
_debug_user_ param0 param0 0 0 0
Run Code Online (Sandbox Code Playgroud)
我想让它像
Alice param1 param2345 32768 50 16
Bob param2345 param1 512 10 1
_debug_user_ param0 param0 0 0 0
Run Code Online (Sandbox Code Playgroud) 我想在行首用“this”替换“-from”。当该行末尾有“R”且其上方的行末尾有“D”时,应该会发生这种情况。
例如对于下面显示的块:
-from XXXXXXXXXXXXXXXXX/D
-from XXXXXXXXXXXXXXXXX/R
-from XXXXXXXXXXXXXXXXX/K
-from XXXXXXXXXXXXXXXXX/L
-from XXXXXXXXXXXXXXXXX/G
-from XXXXXXXXXXXXXXXXX/R
Run Code Online (Sandbox Code Playgroud)
输出应如下所示:
-from XXXXXXXXXXXXXXXXX/D
-this XXXXXXXXXXXXXXXXX/R
-from XXXXXXXXXXXXXXXXX/K
-from XXXXXXXXXXXXXXXXX/L
-from XXXXXXXXXXXXXXXXX/G
-from XXXXXXXXXXXXXXXXX/R
Run Code Online (Sandbox Code Playgroud)
什么是好的,sed
,awk
,grep
,等。
我正在使用 Kubuntu 14.04。当我退出终端模拟器(konsole 或 yakuake)时,kill -9 $$
它不会关闭,并说:
警告:程序“/bin/bash”崩溃了。
如何禁用此行为并强制终端模拟器在 shell 被杀死时静默关闭?
在同一个系统中,当提示kill -9 $$
in 时xterm
,它退出没有任何崩溃报告。
我不记得我在哪些 Linux 发行版中看到了这种“无声”的开箱即用行为,但确实有一些。
更新:这样做的原因是退出终端模拟器而不将历史记录保存到.bash_history
.