2014-09-01 68 views
0

我需要幫助將文件中的多個if語句分開。在文本文件中添加特殊字符後的空格

變化:

[[ "$File1" == "Word1" ]] || [[ "$File1" == "Word2" ]] || 

到:

[[ "$File1" == "Word1" ]] || 
[[ "$File1" == "Word2" ]] || 

的一切,我在網上找到不符合特殊字符,如工作|| 我想我需要使用awk或sed,但我不確定如何讓它工作。

回答

0

您還可以使用awk

awk '{sub(/\|\| /,"&"RS)}1' file 

echo "[[ "$File1" == "Word1" ]] || [[ "$File1" == "Word2" ]] ||" | awk '{sub(/\|\| /,"&"RS)}1' 
[[ == Word1 ]] || 
[[ == Word2 ]] ||