Tag Archive for 'Kaz Kylheku'

Hash’em all

I’ve just released Hash’em all: a Bash script which substitutes recursively the content of the files of a folder with their own sha1sum (changing it to compute a different chechsum is pretty trivial of course). It is a modified version of the already hacked script written by Kaz Kylheku.

As Kaz wrote in 2000:

What is nice about this is that you can embed the function into your shell script. The function changes the current working directory as it descends. So it can handle arbitrarily deep paths. Whereas paths generated by the find command can cause a problem when they get too long; the kernel has a hard limit on the length of the string passed to the open() and other system calls.

It uses sponge from the lovely moreutils tools… and no, the name of the script is not a tribute to the well known trash metal album. :)

If you enjoyed this post, make sure you subscribe to my RSS feed!

A script to make a folder UNIX-like

Sometimes I have to deal with people who use a tentatively OS that, among other things, doesn’t understand UNIX-like permissions :).

I modified a bash script of Kaz Kylheku (found in bash-doc) which for a given folder recursively changes:

  • the permissions of all its files to 644 (and “dos2unix” them);
  • the permissions of all its subdirectories to 755

You can find it here.

UPDATE (2007-01-11): it doesn’t make sense to run dos2unix against a non text file so I have just uploaded here a “-t” version that processes with dos2unix only some kind of file as in:
if [[ "$file" =~ '[css|html|js|php]$’ ]]; then
dos2unix $file
fi

If you enjoyed this post, make sure you subscribe to my RSS feed!