2
我試圖改變從這個文件中的文本:如何使用sed交換兩列?
file.txt,c:\path\to\file
file.txt,c:\path with spaces\to\file
file.txt,c:\path\to\file with spaces
file.txt,c:\path\to\file with spaces
file.txt,c:\path\to\file with spaces
對於這種輸出的(一個文件路徑):
c:\path\to\file\file.txt
c:\path with spaces\to\file\file.txt
c:\path\to\file with spaces\file.txt
c:\path\to\file with spaces\file.txt
c:\path\to\file with spaces\file.txt
這種近乎工作,但需要一個' 「,在該行的末尾:
sed '[email protected]\(.*\),\(.*\),\(.*\)@\2,\1,\[email protected]' file
任何幫助,將不勝感激,我不知道SED那麼好......
編輯
這爲我工作,但我仍想在裏面添加一個 「\」:
sed '[email protected]\(.*\),\(.*\)@\2,\1,\[email protected]' file
謝謝Sed神!! :-) –
@MikeQ,不客氣。但是,我更喜歡'awk';) – Alexander
啊!我也是,我更喜歡awk,但我實際上在批處理中使用gnu awk(不要問),它害怕造成問題的空間...... –