Today, for some reason I have yet to discover, my soft linked directories (created with ln -s <SOURCE> <TARGET>) became unsearchable by the bash find command.
I had to resort to creating a C program, in order to use it's link function.
SOURCE
#include <unistd.h>
#include <stdio.h>
#include <string.h>
/*
Purpose: To create a hard link to a directory
Install: gcc hln.c -o hln
*/
int main(int argc, char* argv[]) {
//Make sure we have the right arguments
if (argc != 3) {
fprintf(stderr,"Usage: hln <SOURCE_DIRECTORY> <TARGET_DIRECTORY>\n\n");
fprintf(stderr,"To later unlink target directory: hln -u <TARGET_DIRECTORY>\n");
return 1;
}
int ret = 0;
if(strcmp(argv[1], "-u") == 0)
ret = unlink(argv[2]);
else
ret = link(argv[1],argv[2]);
if (ret != 0)
perror("hardlink");
return ret;
}
Compile it
After compiling, you'll want to copy the hln executable to a suitable directory, like /usr/bin.
$ gcc hln.c -o hln
thank you, good tool, can you share a compiled version?
ReplyDeleteGood Post! Thank you so much for sharing this pretty post, it was so good to read and useful to improve my knowledge as updated one, keep blogging.
ReplyDeletepython internship | web development internship |internship for mechanical engineering students |mechanical engineering internships |java training in chennai |internship for 1st year engineering students |online internships for cse students |online internship for engineering students |internship for ece students |data science internships