我有一個for循環,循環幾行。每行有兩個字符串與標籤分離它們e.g對包含帶有製表符的字符串的變量grep
chr11 105804693
當我通過可變與文件到grep來搜索在它返回
"105804693: No such file or directory"
。我的代碼如下所示:
for line in $(cat list_of_lines); do grep $ line file_to_search_in >> output_file; 做
我試圖printf
的變量,它返回"chr11"
但是當我附和變量,它返回"chr11 105804693"
我如何可以調用的變量grep和有它搜索全行?
請將您的代碼添加到您的問題。 – Cyrus
如果您從循環體調用'grep',可能會有更好的解決方案,只涉及調用'grep'一次。 – chepner
wrt'我有一個for循環,循環幾行 - - 第一句標識你的問題的根源。請參閱[爲什麼要使用shell循環處理文本被認爲是壞習慣](http://unix.stackexchange.com/questions/169716/why-is-using-a-shell回到流程文本被認爲是不好的做法) –