在我的一堂计算机科学课上,我的老师给了我们一个用户档案:users.txt。文件的行如下所示:
$ head users.txt
root:x:0:0:root:/root:/bin/bash
apache:x:71:71:system user for apache2:/var/www:/bin/sh
ftp:x:73:73:system user for proftpd:/var/ftp:/bin/false
c0407115:x:1501:1000:Alberto Damiao Canelas Fraga:/home/c0407115:/bin/bash
c0407165:x:1502
为了使代码正常运行,我创建了一个名为new_user.txt的txt文件,格式如下(应该遵循/etc/passwd)
doejjan:x:Doe, Jane Joe+111222:home/STUDENTS/teststu:/bin/bash
smidjoh:x:Smith, John Jay+222333:home/STUDENTS/teststu:/bin/bash
我想尝试显示为显示屏幕上的每一条记录而创建的命令,下面是我到目前为止所拥有的:
#!/bin/bash
while read -r line || [[ -n "$line" ]]; do
我希望将*.mk类型的所有文件存储在子目录中的变量中,然后在我的程序中使用它。我试过用下面的命令,但它不起作用。
Shell脚本:
for i in `find . -name *.mk` do
echo $i
done
它显示在错误信息下面。bash:./make_files.sh:第6行:意外令牌附近的语法错误echo' bash: ./make_files.sh: line 6:回显$i‘
它没有打印任何东西。
我想编写一个bash脚本,它模拟Korn命令:cd old new,它在PWD中用new代替old,然后尝试将cd转到新目录。
下面是脚本:
#!/usr/bin/env bash
function korn_cd
{
case "$#" in
0 | 1 ) builtin cd $1 ;;
2 ) if ! echo "$PWD" | grep "$old" ; then
echo "bash: cd: bad subsitiution";
以这种方式尝试:
#!/bin/bash
myvals=`psql -d mydb -c "select id from table1 where 't'"`
ssh user1@host1.domain.tld "for i in $myvals; do echo \$i >> values; done"
只要psql只返回一个值,它就能正常工作。但如果它有几个值,我会收到这样的答复:
bash: -c: line 1: syntax error near unexpected token `2'
bash: -c: li
我用这个包运行bash:
use Symfony\Component\Process\Process;
use Symfony\Component\Process\Exception\ProcessFailedException;
当我想在laravel里运行我的bash时,我犯了这个错误:
进程*/my.sh超过了60秒的超时时间。
$process = new Process('sh ***/my.sh');
$process->run();
// executes after the command finishes
我尝试启动ROR when machine starts.following this
但是当我在/etc/init下测试my_program脚本时,我得到了这个错误信息: /home/usr/.rvm/gems/ruby-1.9.3-p448/gems/bundler-1.3.5/lib/bundler/runtime.rb:33:in‘`block in setup':你已经激活了1.5.2机架,但是你的Gemfile需要1.4.5机架。使用bundle exec可以解决这个问题。(Gem::LoadError)
我谷歌了,并尝试删除机架1.5.2 ...it不工作,错误信息说它
我是韩国人。所以我们用韩国文件名。但我用的是TortoiseGit和Cygwin。犯错误。当我使用TortoiseGit时,这条错误消息。但我用Cygwin它会起作用的。
这是错误信息。
git.exe update-index [...]
/usr/bin/bash: /bin/git.exe update-index -- "새 텍스트 문서.txt": No such file or directory
git did not exit cleanly (exit code 127)
TortoiseGit设置
通用-> Git for Git.exe Path :
当我在Linux机器上运行bash脚本时,我们在日志中得到以下错误:
注意-我们在脚本中设置:
exec > $log 2>&1 , ( in order to send all standard error/output to $log )
错误信息:
tput: No value for $TERM and no -T specified
为了过滤这些错误消息,我们尝试在bash脚本中设置如下:
export TERM=xterm
但没有帮助
在挖掘之后,我们发现在某些情况下发生了这种情况,例如,当我们对远程机器执行ssh并通过ssh在远程计算机上运行命令时。
为
当我在Linux机器上运行bash脚本时,我们在日志中得到以下错误:
注意-我们在脚本中设置:
exec > $log 2>&1 , ( in order to send all standard error/output to $log )
错误信息:
tput: No value for $TERM and no -T specified
为了过滤这些错误消息,我们尝试在bash脚本中设置如下:
export TERM=xterm
没有帮助的but
在挖掘之后,我们发现在某些情况下发生了这种情况,例如,当我们对远程机器执行ssh并通过ssh在远程计算机上运行命令
我试图复制一个名为setup_envs.sh的bash文件,它位于我的Dockerfile的同一个目录中。
在创建Dockerfile之后,如何只运行这个bash文件一次?
我的代码是(在Dockerfile末尾):
RUN mkdir -p /scripts
COPY setup_env.sh /scripts
WORKDIR /scripts
RUN chmod +x /scripts/setup_env.sh
CMD [./scripts/setup_env.sh]
当前错误: /bin/bash: [./scripts/setup_env.sh]: No such file or di