如何使用Bash遍历文本文件的每一行?
使用此脚本:
echo "Start!"
for p in (peptides.txt)
do
echo "${p}"
done
我在屏幕上看到这个输出:
Start!
./runPep.sh: line 3: syntax error near unexpected token `('
./runPep.sh: line 3: `for p in (peptides.txt)'
(后来我想用$p做一些比输出到屏幕更复杂的事情。)
环境变量SHELL是(来自env):
SHELL=/bin/bash
/bin/bash—版本输出:
GNU bash, version 3.1.17(1)-release (x86_64-suse-linux-gnu)
Copyright (C) 2005 Free Software Foundation, Inc.
cat/proc/version输出:
Linux version 2.6.18.2-34-default (geeko@buildhost) (gcc version 4.1.2 20061115 (prerelease) (SUSE Linux)) #1 SMP Mon Nov 27 11:46:27 UTC 2006
peptides.txt文件包含:
RKEKNVQ
IPKKLLQK
QYFHQLEKMNVK
IPKKLLQK
GDLSTALEVAIDCYEK
QYFHQLEKMNVKIPENIYR
RKEKNVQ
VLAKHGKLQDAIN
ILGFMK
LEDVALQILL