我正在学习本教程,学习bash脚本,为我自动完成一些任务.我正在使用putty连接到服务器.
该脚本位于.../Documents/LOG:
#!/bin/bash
# My first script
echo "Hello World!"
Run Code Online (Sandbox Code Playgroud)
我为读/写/执行权限执行了以下操作
chmod 755 my_script
Run Code Online (Sandbox Code Playgroud)
然后,当我进入时./my_script,我收到标题中给出的错误.
一些类似的问题想看到这些,所以我认为它们可能有所帮助:
which bash
Run Code Online (Sandbox Code Playgroud)
/斌/庆典
和
echo $PATH
Run Code Online (Sandbox Code Playgroud)
在/ usr/local/sbin中:在/ usr/local/bin目录:/ usr/sbin目录:在/ usr/bin中:/ sbin目录:/ bin中:在/ usr /游戏:在/ usr/bin中/ MH
我尝试添加当前目录PATH,但这不起作用..
我需要循环一些值,
for i in $(seq $first $last)
do
does something here
done
Run Code Online (Sandbox Code Playgroud)
对于$first和$last,我需要它是固定长度5.所以如果输入是1,我需要在前面添加零,使它成为00001.它循环直到99999例如,但长度必须是5.
如:00002,00042,00212,012312等等.
关于我如何做到这一点的任何想法?
我一直在尝试在我的12系统上安装lpng142.对我来说似乎是一个问题.我收到这个错误
[root@localhost lpng142]# ./configure
bash: ./configure: /bin/sh^M: bad interpreter: No such file or directory
[root@localhost lpng142]#
Run Code Online (Sandbox Code Playgroud)
我该如何解决?该/etc/fstab文件中:
#
# /etc/fstab
# Created by anaconda on Wed May 26 18:12:05 2010
#
# Accessible filesystems, by reference, are maintained under '/dev/disk'
# See man pages fstab(5), findfs(8), mount(8) and/or blkid(8) for more info
#
/dev/mapper/VolGroup-lv_root / ext4 defaults 1 1
UUID=ce67cf79-22c3-45d4-8374-bd0075617cc8 /boot ext4
defaults 1 2
/dev/mapper/VolGroup-lv_swap swap swap defaults 0 0
tmpfs /dev/shm tmpfs defaults 0 0
devpts …Run Code Online (Sandbox Code Playgroud) 我想在shell脚本中执行mongo命令.
我尝试了以下方式test.sh
#!/bin/sh
mongo myDbName
db.mycollection.findOne()
show collections
Run Code Online (Sandbox Code Playgroud)
当我执行上面的脚本./test.sh
然后建立了mongo连接,但未执行下一个命令
如何通过sh脚本[test.sh]执行其他命令?
请帮我
给定一个字符串文件路径/foo/fizzbuzz.bar,如何使用bash只提取fizzbuzz所述字符串的一部分?
我正在使用grep来匹配文件中的字符串.这是一个示例文件:
example one,
example two null,
example three,
example four null,
Run Code Online (Sandbox Code Playgroud)
grep -i null myfile.txt 回报
example two null,
example four null,
Run Code Online (Sandbox Code Playgroud)
如何将匹配的行与其行号一起返回,如下所示:
example two null, - Line number : 2
example four null, - Line number : 4
Total null count : 2
Run Code Online (Sandbox Code Playgroud)
我知道-c返回总匹配的行,但我不知道如何正确格式化以total null count在前面添加,我不知道如何添加行号.
我能做什么?
crontab是否有一个参数来创建cron作业而不使用编辑器(crontab -e).如果是这样,那么代码会从Bash脚本创建一个cronjob?
我可以看到Ctrl+ left/ right跳到行的开头/结尾.如何将此更改为Cmd+ left/ right arrow?
为了获得Alt+ left/ right arrow正确的单词跳跃,请按照本文进行操作.