#!/bin/sh SRCROOT=/vsu/data2/datasource/NPM/fiveminute SRCPATH=NULL MYROOT=/var/monitor/sample MYPATH = NULL CNT=0 MAXCNT=10 `rm -fR $MYROOT` 2>/dev/null for P in $(ls -l -A $SRCROOT|awk '/^d/ {print $9}'); do SRCPATH=$SRCROOT/$P MYPATH=$MYROOT/$P `echo "mkdir -p $MYPATH"` 2>/dev/null `echo "cp $SRCPATH/head.txt $MYPATH/"` 2>/dev/null echo "deal with directory $SRCPATH" CNT=0 for F in $(find $SRCPATH -name *.txt); do `echo "cp $F $MYPATH/"` CNT=`expr $CNT + 1` if [ $CNT -ge $MAXCNT ]; then break be done echo "done" done
A simple shell script
I recently learned about shell programming in linux. I tried to write a small script that traverses the subdirectories of the resource directory and copies 10 files in each resource subdirectory to the target target. There is no technical content, just to prevent yourself from forgetting.
Guess you like
Origin http://10.200.1.11:23101/article/api/json?id=326596424&siteId=291194637
Recommended
Ranking