#!/usr/bin/perl
#written by vaibhav gupta
#Creates a new directory for a given directory and creates links for files.
$dir = $ARGV[0];
&usages unless $dir ;
©
sub usages {
print "Usages: <Dirname> \n";
exit;
}
sub copy {
@result = `find $dir -type d`;
$dirname = `echo "$dir" | rev | cut -d"/" -f 1 | rev`;
chomp $dirname;
$desination = "$dirname";
foreach $d(@result) {
chomp $d;
($a,$b) = split(/$dirname/,$d);
print "Creating $desination$b\n";
# print "[$a -- $b]";
@res = `mkdir -p $desination$b`;
print @res;
}
@result = `find $dir -type f `;
foreach $d(@result) {
chomp $d;
($a,$b) = split(/$dirname/,$d);
print "Copying $d\n";
@res = `ln -s $d $desination$b`;
print @res;
}
}
Subscribe to:
Post Comments (Atom)
3 comments:
http://blog.hackers-cafe.net/2010/04/what-happen-if-you-put-both-str-and.html
Awesome post! Thank you so much for sharing. This entire Blog is fantastic!
good article
Post a Comment