23,219
社区成员
发帖
与我相关
我的任务
分享
awk -F, '{print $2}' test.txt
#!/bin/sh
awk -F, '{
tmp=$2/1000; l1=tmp/100%1000; l2=tmp%100
printf("%s%d/%02d/ %s%d/%02d/ %d.xml\n", "/dir1/",l1,l2,"/dir2/",l1,l2,
$2) }' test.txt > temp.txt
filename=`awk '{print $3}' temp.txt`
for file in $filename
do
dir1=`awk '/'$file'/ {print $1}' temp.txt`
dir2=`awk '/'$file'/ {print $2}' temp.txt`
if test -d $dir2
then
mv $dir1$file $dir2$file
else
mkdir -p $dir2
mv $dir1$file $dir2$file
fi
done
rm -rf temp.txt
test.txt
46791895,2449166600
46791894,2449169430
46791893,2449169431
46791892,2449169432
46791891,2449172071
46791890,2449169310
46791889,2449169311
46791888,2449169200
46791887,2449169312
awk -F, '{
tmp=$2/1000; l1=tmp/100%1000; l2=tmp%100
printf("%s%d/%02d/%d.xml %s%d/%02d/%d.xml\n", "/dir1/",l1,l2,$2, "/dir2/",l1,l2,$2) }' test.txt
/dir1/491/66/2449166600 /dir2/491/66/2449166600
/dir1/491/69/2449169430 /dir2/491/69/2449169430
/dir1/491/69/2449169431 /dir2/491/69/2449169431
/dir1/491/69/2449169432 /dir2/491/69/2449169432
/dir1/491/72/2449172071 /dir2/491/72/2449172071
/dir1/491/69/2449169310 /dir2/491/69/2449169310
/dir1/491/69/2449169311 /dir2/491/69/2449169311
/dir1/491/69/2449169200 /dir2/491/69/2449169200
/dir1/491/69/2449169312 /dir2/491/69/2449169312
rm -rf `awk -F, '{print $2}' test.txt`