进入原目录执行
for i in `ls *`; do cp $i /目的目录/${i%.*}_${i##*.}.log; done
#2
cp 最好带上 -a
#3
佩服rucypli!!!
#4
备份
#!/bin/bash
SRC_FOLDER=/var/tmp/folder1
DST_FOLDER=/var/tmp/folder2
for i in $SRC_FOLDER/*.c $SRC_FOLDER/*.h; do
fileName=`basename $i`
cp -p $i $DST_FOLDER/${fileName%.*}_${fileName##*.}.log
done
还原
#!/bin/bash
SRC_FOLDER=/var/tmp/folder1
DST_FOLDER=/var/tmp/folder2
for i in $DST_FOLDER/*.log; do
fileName=`basename $i`
fileExt=${fileName%.log}
filePre=${fileName%_?.log}
cp -p $i $SRC_FOLDER/${filePre}.${fileExt##*_}
done
进入原目录执行
for i in `ls *`; do cp $i /目的目录/${i%.*}_${i##*.}.log; done
很厉害
#1
进入原目录执行
for i in `ls *`; do cp $i /目的目录/${i%.*}_${i##*.}.log; done
#2
cp 最好带上 -a
#3
佩服rucypli!!!
#4
备份
#!/bin/bash
SRC_FOLDER=/var/tmp/folder1
DST_FOLDER=/var/tmp/folder2
for i in $SRC_FOLDER/*.c $SRC_FOLDER/*.h; do
fileName=`basename $i`
cp -p $i $DST_FOLDER/${fileName%.*}_${fileName##*.}.log
done
还原
#!/bin/bash
SRC_FOLDER=/var/tmp/folder1
DST_FOLDER=/var/tmp/folder2
for i in $DST_FOLDER/*.log; do
fileName=`basename $i`
fileExt=${fileName%.log}
filePre=${fileName%_?.log}
cp -p $i $SRC_FOLDER/${filePre}.${fileExt##*_}
done
#5
备份
#!/bin/bash
SRC_FOLDER=/var/tmp/folder1
DST_FOLDER=/var/tmp/folder2
for i in $SRC_FOLDER/*.c $SRC_FOLDER/*.h; do
fileName=`basename $i`
cp -p $i $DST_FOLDER/${fileName%.*}_${fileName##*.}.log
done
还原
#!/bin/bash
SRC_FOLDER=/var/tmp/folder1
DST_FOLDER=/var/tmp/folder2
for i in $DST_FOLDER/*.log; do
fileName=`basename $i`
fileExt=${fileName%.log}
filePre=${fileName%_?.log}
cp -p $i $SRC_FOLDER/${filePre}.${fileExt##*_}
done
#!/bin/bash
SRC_FOLDER=/var/tmp/folder1
DST_FOLDER=/var/tmp/folder2
for i in $SRC_FOLDER/*.c $SRC_FOLDER/*.h; do
fileName=`basename $i`
cp -p $i $DST_FOLDER/${fileName%.*}_${fileName##*.}.log
done
还原
#!/bin/bash
SRC_FOLDER=/var/tmp/folder1
DST_FOLDER=/var/tmp/folder2
for i in $DST_FOLDER/*.log; do
fileName=`basename $i`
fileExt=${fileName%.log}
filePre=${fileName%_?.log}
cp -p $i $SRC_FOLDER/${filePre}.${fileExt##*_}
done
#!/bin/bash
SRC_FOLDER=/var/tmp/folder1
DST_FOLDER=/var/tmp/folder2
for i in $SRC_FOLDER/*.c $SRC_FOLDER/*.h; do
fileName=`basename $i`
cp -p $i $DST_FOLDER/${fileName%.*}_${fileName##*.}.log
done
还原
#!/bin/bash
SRC_FOLDER=/var/tmp/folder1
DST_FOLDER=/var/tmp/folder2
for i in $DST_FOLDER/*.log; do
fileName=`basename $i`
fileExt=${fileName%.log}
filePre=${fileName%_?.log}
cp -p $i $SRC_FOLDER/${filePre}.${fileExt##*_}
done