Summary of shell script cases in Linux

1. Business scenario: The data format we need is xxx.zip, and the data format given to us by the actual data provider is xxx_000000.zip. There are hundreds of such files or even the previous one. Manual modification may be unrealistic. , Scripting is a good choice

Several pieces of simulated data
Insert picture description here
. Script case written by me

 #!/bin/bash

 for file in `ls | grep .zip`
 do 
 
 newfile=`echo $file | sed 's/_000000//g'`
 mv $file $newfile
done

The data format after executing the script processing is as follows
Insert picture description here

Guess you like

Origin blog.csdn.net/qq_38220334/article/details/108791430