在我的.bashrc文件中的终端提示定义中,除其他外,我有以下代码片段:
${debian_chroot:+($debian_chroot)}
Run Code Online (Sandbox Code Playgroud)
这有什么作用,我需要它吗?
基于搜索各种论坛,我遇到了一个似乎并不常见的问题。
我无法运行 Make 命令。
信息:
The program 'make' is currently not installed. You can install it by typing:
sudo apt-get install make
Run Code Online (Sandbox Code Playgroud)
所以这样做:
sudo apt-get install make
Reading package lists... Done
Building dependency tree
Reading state information... Done
make is already the newest version.
0 upgraded, 0 newly installed, 0 to remove and 4 not upgraded.
Run Code Online (Sandbox Code Playgroud)
但是当我尝试运行 Make 时,我得到了相同的消息。这是怎么回事?
编辑:Ubuntu 12.04 64 位桌面全新安装。
我正在尝试了解 Ubuntu 上的系统管理。所以,作为一个例子,我创建一个虚拟用户使用
sudo useradd -d /home/linda linda
Run Code Online (Sandbox Code Playgroud)
并passwd创建密码。我检查是否已使用输入cat /etc/passwd
linda:x:1004:1004::/home/linda:/bin/sh
Run Code Online (Sandbox Code Playgroud)
然而,当我su - linda,我得到
Run Code Online (Sandbox Code Playgroud)No directory, logging in with HOME=/
事实上,还没有创建主目录。我错过了什么?
谢谢。
如何在不打开文本文件的情况下清除文本文件中存在的文本?
我的意思是,例如我有一个文件,hello.txt其中包含一些文本数据,如何在不打开该文件的情况下清除该文件中的全部文本?
我的意思是不使用任何编辑器,如 nano、Gedit 等。
挣扎了一段时间将数组作为参数传递,但无论如何它都不起作用。我试过如下:
#! /bin/bash
function copyFiles{
arr="$1"
for i in "${arr[@]}";
do
echo "$i"
done
}
array=("one" "two" "three")
copyFiles $array
Run Code Online (Sandbox Code Playgroud)
有解释的答案会很好。
编辑:基本上,我最终会从另一个脚本文件调用该函数。如果可能,请解释限制条件。
考虑以下 bash 提示,其中^表示提示位置:
$ git commit -am "[bug 123456] Do this and that with the bug"
^
Run Code Online (Sandbox Code Playgroud)
假设我想用不同的提交消息再次提交同一个错误。有没有办法从光标位置删除文本直到行尾?
我正在使用 Ubuntu 11.10。我ssh每天都用于连接许多服务器,所以我将它们的参数放在.ssh/config文件中,如下所示:
Host Home
User netmoon
Port 22
HostName test.com
Run Code Online (Sandbox Code Playgroud)
有没有办法将每个连接的密码放在这个文件中,这样,当服务器要求输入密码时,终端输入其密码并将其发送到服务器?
我需要这个,因为有时我远离电脑,当我回去时,输入密码并按Enter终端说CONNECTION CLOSED。
PS 我不想使用公钥/私钥对。
我正在尝试将 bash 命令的输出重定向到一个新文件中。
如果我尝试如下管道:
ls -la | vim
Run Code Online (Sandbox Code Playgroud)
Bash 向我展示了错误:
Vim: Error reading input, exiting...
Vim: preserving files...
Vim: Finished.
Run Code Online (Sandbox Code Playgroud)
我知道我可以打开 Vim 然后使用:
:r !ls -la
Run Code Online (Sandbox Code Playgroud)
但是有没有办法在 bash 本身中做到这一点,以便打开 Vim 并将输出自动粘贴到那里?