linux in the batch file to add the prefix operation

Need to add the file name "gt_" within the folder in front of all the txt file;

Is the original file "xxx.txt" become "gt_xxx.txt":

Script to search the Internet as follows:

for i in `ls`;
do mv -f $i 'echo "gt_"$i`;
done

1, first of all, linux command line switches below you need to modify the file name of the directory:

cd destination directory

2, the new sh file in that directory:

touch xxx.sh

3, open xxx.sh file:

vim xxx.sh

3. Copy the contents of the script just to the sh file, save and exit

Edit sh file: Shift + I

After the adhesive save and exit: Ctrl + Alt + D to exit edit mode, then enter: wq Quit!

Execute sh file: ./ xxx.sh

 

 

Not previously come into contact with linux commands, now we need to use some, hereby notes as a memorandum ~~~

 

Guess you like

Origin www.cnblogs.com/zzc-Andy/p/11987969.html