How do you recursively unzip archives in a directory and its subdirectories from the Unix command-line?

If you want to extract the files to the respective folder you can try this find . -name “*.zip” | while read filename; do unzip -o -d “`dirname “$filename”`” “$filename”; done; A multi-processed version for systems that can handle high I/O: find . -name “*.zip” | xargs -P 5 -I fileName sh -c ‘unzip -o … Read more

How to strip all whitespace from string

Taking advantage of str.split’s behavior with no sep parameter: >>> s = ” \t foo \n bar ” >>> “”.join(s.split()) ‘foobar’ If you just want to remove spaces instead of all whitespace: >>> s.replace(” “, “”) ‘\tfoo\nbar’ Premature optimization Even though efficiency isn’t the primary goal—writing clear code is—here are some initial timings: $ python … Read more

Runtime.exec on argument containing multiple spaces

Ok, this is not simply an update but also an answer so I’m filing it as one. According to all information I could find, the following should theoretically do it: String[] cmd = {“explorer.exe”, “/select,\”C:\New”, “”, “”, “”, “”, “”, “”, “Folder\file.txt\””}; The multiple spaces have been broken into empty strings and the array version … Read more

Faster way to remove ‘extra’ spaces (more than 1) from a large range of cells using VBA for Excel

Late to the party but… There is no need for iteration through cells/values nor a recursive function to search and replace multiple spaces in a range. Application.Trim wil actually take care of multiple spaces between words (and will trim leading/trailing spaces) leaving single spaces in between words intact. The great thing about it, is that … Read more

Bash variables with spaces

Execute it like this: “$VAR”. This is one of the most significant gotchas in shell scripting because strings are always substituted literally and any contained spaces are treated as token delimiters rather than as characters of the string. Think of substituting a variable as a kind of code pasting at runtime. What really happens when … Read more