Just to follow up on the discussion of interesting BASH tricks last night, here is how one could implement file system traversal if find didn't exist. Note that GLOBIGNORE isn't always required to be explicitly set as shown for the root and parent directory to be excluded, but this does as required and provides clarity.
#!/bin/bash GLOBIGNORE=". .." # Ignore the current and parent directory # This will be implicit with GLOBIGNORE not null, although . and .. can still # be explicitly selected if nullglob and failglob aren't set
descend() { for i in * .*; do if [ -d "$i" ]; then pushd "$i" descend # Do things to files in the directory here popd fi done }
descend # end script
Also, Douglas Adams on the Galactic Presidency is translated by the jive filter:
Anyone willin' an' capable t'git demselves elected President by no means should be allowed t'do de job. What it is, Mama!
Or Hanlon's Razor as presented by a Swedish chef:
Nefer ettreeboote-a tu meleece-a thet vheech is edeqooetely ixpleeened by stoopeedity.
Yes, the filters package is endless fun.
I'd mostly forgotten about the filters like Chef. I used to take some juvenile amusement in piping articles from rec.arts.erotica through those for that special Sexy Swedish Chef.
Geoffrey Jacobs gdjacobs@curets.ca writes:
Just to follow up on the discussion of interesting BASH tricks last night, here is how one could implement file system traversal if find didn't exist. Note that GLOBIGNORE isn't always required to be explicitly set as shown for the root and parent directory to be excluded, but this does as required and provides clarity.
#!/bin/bash GLOBIGNORE=". .." # Ignore the current and parent directory # This will be implicit with GLOBIGNORE not null, although . and .. can still # be explicitly selected if nullglob and failglob aren't set
descend() { for i in * .*; do if [ -d "$i" ]; then pushd "$i" descend # Do things to files in the directory here popd fi done }
descend # end script
Also, Douglas Adams on the Galactic Presidency is translated by the jive filter:
Anyone willin' an' capable t'git demselves elected President by no means should be allowed t'do de job. What it is, Mama!
Or Hanlon's Razor as presented by a Swedish chef:
Nefer ettreeboote-a tu meleece-a thet vheech is edeqooetely ixpleeened by stoopeedity.
Yes, the filters package is endless fun.
Roundtable mailing list Roundtable@muug.ca https://muug.ca/mailman/listinfo/roundtable