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"
相关文章
相关标签/搜索