说我的密码在~/myproject/,我有一个文件~/myproject/scripts/com/example/module/run_main_script.sh
在带有ctrlp 插件的vim 中,我可以按Ctrl+ P,输入run_main_ Enter,我正在编辑该脚本。
我想在 bash 中运行该脚本(带有一些参数)。而且我不想输入完整路径。有没有办法在 bash 中做到这一点?
我正在使用终端版本 2.2.3 (303.2)。
问题是当我尝试从 root 开始更改目录时,我必须双击某些目录才能获得尾部斜杠。
例如,我开始输入
cd /etTab
它给了我:
/etc
然后我必须再次点击 Tab 以获得所需的尾部斜杠
/etc/
然后,最后,我可以Tab使用单选项卡点击所有其他目录。
我怎样才能解决这个问题?我非常想念 Ubuntu 的 bash。
我对 bash 很陌生,所以如果我问一些愚蠢的问题,我很抱歉。长话短说,我正在尝试运行以下 bash 脚本:
#!/bin/sh
ACTION="init" # init or push
USERNAME="username"
PASSWORD="password"
HOST="host.com"
PATH="WebSite/app"
DRYRUN="-D" # use -D for dry-run
cd ./htdocs/app/
git checkout master # switch to master
git push # push to origin
git ftp $ACTION --user $USERNAME --passwd $PASSWORD $DRYRUN ftp://$HOST/$PATH
Run Code Online (Sandbox Code Playgroud)
但是当我这样做时,我收到以下错误:
deploy.sh: line 12: git: command not found
deploy.sh: line 13: git: command not found
deploy.sh: line 14: git: command not found
Run Code Online (Sandbox Code Playgroud)
如果我自己直接按照脚本中的步骤操作,它会按预期工作,但在通过 bash 运行时却不会。
我认为这可能与 git 不在我的 $PATH 中有关,它看起来像这样:/home/daniel/.rvm/gems/ruby-1.9.3-p286/bin:/home/daniel/.rvm/gems/ruby-1.9.3-p286@global/bin:/home/daniel/.rvm/rubies/ruby-1.9.3-p286/bin:/home/daniel/.rvm/bin:/usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games:/home/daniel/.rvm/bin但如果是这样,那么我不确定如何添加它。
有人可以帮忙吗?谢谢 :)
我ssh server -L 3392:192.168.1.138:3389在一个终端窗口中运行,然后rdesktop 127.0.0.1:3392在另一个窗口中运行以通过 SSH 隧道连接到 Windows 机器。如何将其合并为一个可以从 Gnome 快捷方式或其他方式运行的命令?
这已经让我度过了愉快的半天,我确信这样的解决方案必须存在(如果没有,那么我正在编写一个),但是唉,问题就在这里。
我有两个文件,hpc.sorted.modules.txt和bduc.sorted.modules.txt. 我想要完成的是显示两个文件的并排比较,其中任何不在任一文件中的更改都在其空列中。我不想diff附加到同一行,> <或者|如果它们不匹配。
示例输出:http : //pastebin.com/raw.php?i=sr20gyWz使用
diff -y -W 100 hpc.sorted.new.list bduc.sorted.new.list
Run Code Online (Sandbox Code Playgroud)
为了进一步强调这一点,如果你看一下这个例子,这条线:
bfast/0.7.0a | bedtools/2.6.1
Run Code Online (Sandbox Code Playgroud)
不应该存在。相反,它们应该在单独的行上,在左列或右列中有一个空行。
我不知道我做了什么,但突然间我不能使用任何命令,只能使用 sudo 开头。无论我得到什么命令 bash: /home/otis/bin/ls: cannot execute binary file。即使 cp 我得到 bash: /home/otis/bin/cp: cannot execute binary file。如果我把 sudo 放在一切都好之前。如何更正此问题,以便不必以超级用户身份执行每个命令。
我想使用 telnet 连接到远程主机,只是没有用户名/密码验证
telnet remotehost
Run Code Online (Sandbox Code Playgroud)
然后我需要输入一些命令进行初始化
然后我需要重复以下命令:
cmd argument
Run Code Online (Sandbox Code Playgroud)
参数是从本地文件中读取的,在这个文件中有很多行,每一行是一个参数,运行一个“cmd参数”后,远程主机会输出一些结果它可能会输出一行“OK”或输出很多行,其中之一是字符串“ERROR”,我需要根据结果做一些事情。
基本上,脚本是这样的:
initialization_cmd #some initial comands
while read line
do
cmd $line
#here the remote host will output results, how can I put the results into a variable?
# here I want to judge the results, like
if $results contain "OK";then
echo $line >>good_result_log
else
echo $line >> bad_result_log
fi
done < local_file
the good_result_log and bad_result_log are local files
Run Code Online (Sandbox Code Playgroud)
有可能吗?谢谢!
注意:我无法控制 B,我只能在 B 上运行初始 cmds 和 cmd $line
例如我输入
cat /very/long/path/textfile
Run Code Online (Sandbox Code Playgroud)
在那之后我决定给出下一个命令
rm /very/long/path/textfile
Run Code Online (Sandbox Code Playgroud)
所以,我的问题是:替换上一个命令的第一个单词的最简单/最快的方法是什么?(没有箭头键或复制粘贴)
它应该适用于任何命令(cat、rm 和 textfile 仅用于此示例,它不必是那些)
看下面的命令
# ps ax | grep bitlbee
2271 ? Ss 0:00 /usr/bin/bitlbee -s mysql -c /root/config.conf
3930 ? S 0:00 /usr/bin/bitlbee -s mysql -c /root/config.conf
Run Code Online (Sandbox Code Playgroud)
请参阅 STAT 列。这是解释
S Interruptible sleep (waiting for an event to complete)
s is a session leader
Run Code Online (Sandbox Code Playgroud)
这里的会话负责人是什么?还有这里的会话是什么?我怎么知道这两个进程中的哪一个是活动的?
我已经习惯了其他语言的这种风格:
do_something || (log_error; return 1) # do something, and if that fails, log the error and then return 1 no matter what, even if the logging fails.
Run Code Online (Sandbox Code Playgroud)
但我似乎无法在 bash 中找到等价物。问题是括号的工作有点像一个有自己作用域的函数,返回 1 不会有预期的行为。
到目前为止,这是我所拥有的,但并不完美:
! do_something && log_error && return 1
Run Code Online (Sandbox Code Playgroud)
问题在于!令人困惑,返回1取决于日志记录的成功。
这个更好,但更冗长:
do_something || (log_error; return 1) || return 1
Run Code Online (Sandbox Code Playgroud)
有什么想法吗?