我目前正在读取unix中三个字母字符串的文件,并想知道如何去制作行变量,以便我可以在代码中grep它们...指定一行变量名称Unix
我的想法是这样的:
!#/bin/bash
IFS=''
while read line
do
code=$(line)
#This would be where I want to assign the line a variable
grep "$code" final.txt > deptandcourse.txt
#This is where I would want to grep according to that three letter string
done < strings.txt
示例文件(strings.txt):
ABC
BCA
BDC
我希望把这些信件在变线,然后用grep的文件(final.txt )首先为'ABC',然后是'BCA',然后是'BDC'
'line'是一个变量了。你究竟是什么意思? – 2014-08-31 04:53:37
提供示例文本,以及如何输出。 – Jotne 2014-08-31 05:13:44