因为业务上需要,需要在一大批导出的手机号上修改成相应的sql语句用于insert某一张表中,当然为了快速处理文件就吧文件转化为列式存于文件phone中,然后通过脚本去修改文件,脚本如下:
#!/bin/bash #Used to insert a string at the end of the file list #note:You must configure the yum source #writer jim #histor #2017.3.30 #2017.3.31 ########PATH######## file_path=/usr/local/scripts/phone ########PATH######## /bin/rpm -qa|grep dos2unix#用于判断系统下是否有装过dos2unix,用于转化文件的字符集编码和正则字符定位符 if [ $? -ne 0 ];then yum -y install dos2unix fi /usr/bin/dos2unix $file_path /bin/sed -i "s/^/insert into phonelist (PHONE) values (\‘/g" $file_path /bin/sed -i "s/$/‘);/g" $file_path
时间: 2024-10-26 00:36:39