Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #! /bin/csh
- if ($#argv != 3) then
- echo "Wrong args count!"
- exit 1
- endif
- set dir1="`eval echo $1`"
- set dir2="`eval echo $2`"
- set n="$3"
- if (! -d "$dir1") then
- echo "$dir1 is not a directory"
- exit 1
- endif
- echo
- if(`find "$dir1" -maxdepth 1 -type f | wc -l`< $n) then
- echo "$dir1 has less then $n files"
- exit 1
- endif
- if (! -e "$dir2") then
- mkdir "$dir2"
- endif
- if (! -d "$dir2") then
- echo "$dir2 is not a directory"
- exit 1
- endif
- set minFiles = `find "$dir1" -maxdepth 1 -type f -printf '%s %p\n'| sort -n | head -$n | cut -d' ' -f2-`
- set minFiles = `echo $minFiles | sed 's/ \//\n\//g'| sed 's/ /_SPACE_/g'`
- foreach file ($minFiles)
- set temp = `echo "$file" | sed 's/_SPACE_/ /g'`
- mv "$temp" "$dir2"
- end
- exit 0
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement