|
i**p 发帖数: 902 | 2 Linux bash. a command line is this,
. cs_script.sh
What is the function of the "." ? |
|
|
p****s 发帖数: 32405 | 4 hmm, 我从来都在makefile里直接改这个, bash里也有CFLAGS? |
|
c*******t 发帖数: 55 | 5 各位大侠,最近兄弟新学linux,参考网上的程序改了一个script
来抓取某个进程的CPU使用情况,如果超过一定数值就报警并退出,
我用了两个循环(嵌套的),外循环设定最大扫描次数,内循环
扫描一次“ps -ef”命令的全部返回结果,可是我发现在内循环
中即使触发了退出的条件,在外部循环仍然会继续进行,直至
全部循环结束。我试过了break 和 exit命令,都不起作用,
兄弟这里跪求各位大佬多多指点一下。代码如下(问题在最后那个
break命令,在那一行我试过用exit程序也不提前退出),
#!/bin/bash
usageHelp="Usage: ${0##*/}"
uidHelp="-u starting uid, must be an integer greater than or equal to 0 (
only used with \"-w users\")"
maxCpuHelp="-m max cpu, must be an integer greater than or equal to 0 and
less than 100"
watchHelp="-w wha |
|
L******k 发帖数: 2945 | 6 i only need to tab one time in bash...
type |
|
D******n 发帖数: 2836 | 7 i mean when it is ambigious, bash will beep first , and then u have to type
tab again to see the list. while in tcsh , only one tab is needed. |
|
L******k 发帖数: 2945 | 8 my bash doesnt beep...just tab once
type |
|
|
p*****s 发帖数: 344 | 9 try harder, google man bash, search for
show-all-if-ambiguous
show-all-if-unmodified |
|
p*****s 发帖数: 344 | 10 use bash smart tab completion
search for bash_completion
unsolved
interpret |
|
|
s******7 发帖数: 1758 | 12 求助,我需要运行一些计算程序,这些程序我不能改,我想在运行完程序以后接着运行下一个
程序或者记录一下花了多少时间,发给email通知我
我就写了个脚本
比如:
#!/bin/bash
...
mpi -np 10 firstCprogram
date
mail ...
mpi -np 10 theNextCprogram
问题出在,执行完第一个C program以后, 脚本就停止了, 不运行下一个命令 date了
,这个有办法吗,我也不知道别人的程序里写了啥有没有返回值 |
|
A*******i 发帖数: 75 | 13 例如用命令 grep 'abc' *.* | wc -l
想把wc的结果存到一个变量中
试着用grep 'abc' *.* | wc -l | read var1
但是var1里面没有值,现在暂时办法就是先把值存到一个临时文件里面,然后再读文件
里面的值。
在tcsh里面用set就可以做到,可是bash中好像不行,请问有直接的方法吗?谢谢 |
|
p**i 发帖数: 688 | 14 have you tried
var1=`grep 'abc' *.* | wc -l`
echo $var1
例如用命令 grep 'abc' *.* | wc -l
想把wc的结果存到一个变量中
试着用grep 'abc' *.* | wc -l | read var1
但是var1里面没有值,现在暂时办法就是先把值存到一个临时文件里面,然后再读文件
里面的值。
在tcsh里面用set就可以做到,可是bash中好像不行,请问有直接的方法吗?谢谢 |
|
y***a 发帖数: 840 | 15 我的BASH里用HISTORY命令发现老有些刚刚用过的命令老不打印出来,列出来的命令总
有一些刚用的却不见了。经常是一些比较长的命令丢掉。有见过类似问题的吗? |
|
h******b 发帖数: 52 | 16 【 以下文字转载自 Programming 讨论区 】
发信人: hulalalb (just do it), 信区: Programming
标 题: Bash 里一个简单诡异的问题
发信站: BBS 未名空间站 (Mon Sep 27 11:45:20 2010, 美东)
...
echo $stasc
echo $evtsc
echo $stasc $evtsc
...
运行结果如下
...
19.7
8.40
8.40
...
为防止老花,特意C+V
何解???抓狂...
拜诸位... |
|
m*********g 发帖数: 273 | 17 #!/bin/bash
stasc=19.7
evtsc=8.40
echo $stasc
echo $evtsc
echo $stasc $evtsc
OUTPUT:
mondsailing@thinkpad:$ ./test
19.7
8.40
19.7 8.40 |
|
h******b 发帖数: 52 | 18 这样当然是没问题的。
最后发现大概是$stasc的取值引起的。
我是在脚本里用awk赋值的,所以最后一位是空格引起了这个问题。
但是如果顺序反一下又是正常的即
echo $evtsc $stasc
8.40 19.7
诡异其实是这个地方。
我想可能要么是bash的bug要么是awk的bug.
谢谢诸位了! |
|
g****g 发帖数: 1828 | 19 now i understand. it changed the directory, but only within the subshell
that runs the script.
in your example, bash is a subshell of the current shell, say tcsh. whatever
you do in the subshell does not affect the parent shell. |
|
E*V 发帖数: 17544 | 20 both are right
bash 3.x borrow [[ from ksh |
|
r********s 发帖数: 101 | 21 最近不得不学习 BASH PROGRAMMING。 网上的文本看的眼睛太累,谁能推荐本比较经典
的书籍,适
合于初学者的。谢谢! |
|
h*******x 发帖数: 12808 | 22 你可以去gnu.org里面下载bash的manual,感觉那个挺不错的 |
|
r*****z 发帖数: 906 | 23 learning the bash, O'reilly的 |
|
|
v*****u 发帖数: 92 | 25 ABS : Advanced Bash-Scripting Guide |
|
F*******i 发帖数: 190 | 26 Thanks SSA.
I got this:
echo ${${str}}
bash: ${${str}}: bad substitution
echo ${str}
e
echo $e
123 |
|
|
j*********e 发帖数: 811 | 28 I run a bash-script with command:
for con in 'seq 50 50 300'...
do
replace "count" $ con
compile
run "10" "con_cnt$con"
done
but the result shows, it runs 10 times at 50,100,200,300
by 150 and 250 only 9 times
then I changed a condition, and this time, it runs 10 times at 50,100,150,
300
by 200 and 250 only 8 times
I read the couu_log.txt, and there are several places, that without the sign
why? |
|
g***i 发帖数: 4272 | 29 就是自动显示出所有候选命令。在csh里边是ctrl+d,但是老这样手就不舒服了,还是
习惯在bash里双击tab,有办法改么? |
|
|
d******i 发帖数: 7160 | 31 比如一个bash(root)通过ssh在做一个耗时的安装,
回家后想看看这个安装完成没有,又ssh上去。
是通过ps -A,然后看status吗?
还是有别的办法?
谢谢! |
|
a**U 发帖数: 115 | 32 各位,请问这个问题如何解决?
用putty,bash下输入命令如果长就同行覆盖,而不是另起一行来显示,这个怎么解决
?多谢! |
|
f****p 发帖数: 18483 | 33
bash用的算是最多的。sunos/solaris用的是csh。但是你自己可以配置。 |
|
|
b*******s 发帖数: 5216 | 35 你不觉得ksh的regex有点怪吗?
我还是觉得bash好,起码用的人多 |
|
|
|
s****e 发帖数: 1180 | 38 怎么复习linux, bash呢?这两天我在面试找工作,本人是experienced的。有两年工业
界工作经验。我上一份工作,用的是linux,找第二份工作的时候,有关于linux的面试
题。向版上请教过,得到一本书,挺管用的。但还是不能答上来所有的面试题。
有这样一道面试题。有data如下:
studentname age time
其中studentname有重名的,就是说相同的studentname,有不同的time.题目要求,对
同一个studentname,找出时间最大的那个。并输出所有 non duplicated
studentnames. 用linux commands.
怎么弄?多谢!:) |
|
z*****u 发帖数: 3010 | 39 我建立了下面这个a.sh 脚本, 不知道为什么 mkdir 这一行没有执行
我直接 运行 find -name *.xls | wc -l, 返回值 是9
我用bash -x a.sh
出来的信息是
++ wc -l
++ find -name '*.xls'
+ '['9 -gt 5']'
网上也search了, 实在是不知道哪里出错了
希望有人能够指点一下
a.sh 如下
until [ $(find -name *.xls | wc -l) -gt 5 ] ;
do
mkdir -p folder
break
done |
|
|
n******7 发帖数: 12463 | 41 妈的,用了几个console emulator
bash history都不work
readline倒是好的,ipython里面可以用
换成linux terminal了
这下真爽了 |
|
|
n******7 发帖数: 12463 | 43 不知道
我还是继续用linux term
装了ipython直接在bash.exe里面用啊 |
|
O*t 发帖数: 56 | 44 这个。。。那我宁愿文件浏览器下面直接打开File->"Open command prompt"(或者快
捷方式放到Quck access toolbar上面直接点) cmd里面手动输入个bash.exe。。。懒
得切换win下面的目录了就这么干 |
|
m*******i 发帖数: 362 | 45 lz可以试试用默认的bash跑tmux,我目前用的很舒服。只要不跑带gui的东西,这个wsl
非常强大,满足了我大部分需求。 |
|
d******e 发帖数: 117 | 46 我有一个文本文件1.txt如下:
col1 col2
col1 col2
......
在BASH代码里,我想把1.txt的column 1存入一个数组(或list)里,请问
有什么办法? |
|