→ bibo9901: xargs --verbose 可以看到要執行的 command 07/10 12:52
→ bibo9901: 可能是sed 的參數有問題, 試試用雙引號包起來? 07/10 12:53
我發現可能是文件的編碼問題,list清單是在windows上做的 (剛剛做了好像又不是)
我下 $xargs -t -a ./list
只出現兩行
/home/me/doc/a/123.txtocentxt
/home/me/doc/a/123.txttxt
Orz好想死
推 qsort: -i: This option is deprecated; use -I instead. 07/10 13:25
→ qsort: try this: xargs -I{} -t -n 1 echo {} 07/10 13:26
when I use -I{} instead,got the same result.
I think maybe the issue is encoding of file
※ 編輯: cherubx (61.66.243.96), 07/10/2015 13:47:15
→ bitlife: 試試用vi看一看list檔,把裏面的怪字元除掉,太多列用regex 07/10 13:53
→ bitlife: 如果vi也看不出來,用od來看 07/10 13:54
→ bitlife: 反正先找出有什麼字元是路徑以外的,格式如何再來想辦法 07/10 13:54
不好意思od我不會看,我會再學的Orz
我剛剛直接用vi 在tty上全部手動key上路徑,做出新的list
$cat new-list |xargs -t -I{} sed 's///g' {}
sed s///g /home/me/doc/a/123.txt
sed: can't read /home/me/doc/a/123.txt : No such file or directory
....全都是
$sed s///g /home/me/doc/a/123.txt (照xargs的指令key一遍)
內容出來了!!
我在想是不是原檔的權限問題,我chmod 744後還是一樣...
突然覺得linux可以玩一輩子了T.T
※ 編輯: cherubx (61.66.243.96), 07/10/2015 14:01:48
推 bitlife: 先直接用bash執行 while read p; do sed s///g $p <換行> 07/10 15:15
→ bitlife: done<new-list 07/10 15:15
→ bitlife: 看看有沒有成功? 07/10 15:15
→ bitlife: linux至少還有這些指令可以玩一輩子,在早先的windows,這 07/10 15:16
→ bitlife: 種批次動不寫程式來做要下輩子 XD 07/10 15:17
→ bitlife: ^作 07/10 15:17
→ kdjf: 上傳你的list.txt給大家看一下啊 07/10 19:25
推 kdjf: 為什麼你要xargs -i ? 你的-i是要給sed的吧? 07/10 19:28
-i 不是用來表示{}把前面的結果當引用檔使用嗎?
因為我的程式沒-i 的話{}會讀不到
→ lj0113: 試試 dos2unix 指令, 之前在 windows 處理過有問題的檔案 07/10 22:15
→ lj0113: 之前在 windows 處理過正常, linux有問題的檔案, 都這樣解 07/10 22:16
好了!!!!
我真是太蠢了
謝謝以上各位的幫忙T.T
非常感謝
※ 編輯: cherubx (61.66.243.96), 07/11/2015 11:53:12