print summary of directory, and group all symbolic links
I am trying to get a summary of filetypes in a directory, but the total count of symbolic links is not working. I am stuck at the results of the file command. I have used the find command to confirm my expectations, but my bash function is not giving the results I want.
Here is my function:
And here is my find command to confirm the number of symbolic links:
Result:
Here is my actual output of /etc:
And the expected text:
I know that both file and du are reading the entire directory once apiece, so I am trying to avoid a third read (with find).
I have given some thought to pipe the output to a second /tmp/file, and somehow use the cut -d (delimiter) option to group the symbolic links, and then uniq -c (gasp) again, but in the example above, there are 2 symbolic links to `fedora-release' and my count would be off.
You could replace
with
In all cases, it removes everything up to the first colon, inclusive. In the case of symbolic link, it'll strip away everything beginning with the space after "symbolic link".
Except for deleting the target of a symbolic link, it should yield output identical to your cut approach so that subsequent commands require no modification.
Regards,
Alister
These 2 Users Gave Thanks to alister For This Post:
Hi,
I have a file with more than 1 layers of soft links for it. For ex.
ls -la .profile
.profile@ -> /home/act/.profile_abc
ls -la
/home/act/.profile_abc@ -> .profile_final
I want to get the name of the last file (i.e. .profile_final) when I refer to .profile using shell script. I... (2 Replies)
I've just started using UNIX in a Linux vmplayer. I'm trying to run the command:
ln -s `pwd`/$1 `python -c "from distutils.sysconfig import get_python_lib; print get_python_lib()"`/$1
in a script from an online tutorial, but I keep getting an error message:
ln: creating symbolic link... (1 Reply)
Hi all,
I have scoured the entire forum for this but to no avail unfortunately. Basically, I would like to remove my symbolic link from my folder name i.e.
foldername -> /a/b/c/d/f
where f is indeed a folder. I have tried rmdir but this does not work and in actual fact deletes the... (4 Replies)
I am linking a directory as follows:
ln -sf /home/xxx/userid/real_files/* /home/xxx/userid/linked_files
This gives me symbolic links for all the files in the real_files directory in the linked_files directory. My question is, if I go and remove a file in the real_files directory and then go... (1 Reply)
Hi,
I am writing a unix system utility that is supposed to scan through a directory, collecting
information about the files and subdirectories. That part is going well.
The tricky part is that some files in the directory are hard links or symbolic links. I am supposed to IGNORE these links.... (4 Replies)
Hi,
Is there a limit to the number of symbolic links you can have?
I tried to vi the symbolic link relating to a file and got the following error:
"filename" Too many levels of symbolic links
There is only one symbolic link to one file in this case, but there are >2000 other links to... (2 Replies)