bash 相關的一些小代碼片段

批量修改文件名:html

for i in *.html; do mv $i ${i/oldstring/newstring}; done;

批量替換文件內容:bash

sed -i "s/oldstring/newstring/g" *.html

 按行讀數據,拆分,輸出:spa

#!/bin/bash
while IFS='' read -r line || [[ -n "$line" ]]; do
   IFS='|' read -r -a items <<< "$line"
   printf ",
    (
        '',
        '110',
        '${items[0]}',
        '',
        '${items[1]}'
    )"
done < "$1"
相關文章
相關標籤/搜索