Posts Tagged directory
Changing Directories More Easily
Here is something I have in my Bash config that I have found useful these days. It defines a command called up that lets me move up a given number of directories. For example, up 2 is the same as cd ../.., and up 4 is cd ../../../.., and so on. function up() { cd $(perl -e 'print join("/" => ("..") x shift)' $1) } I found this somewhere online, so I am not taking credit for it. The way this works is we use Perl to create the string ../../.., or however many dots and slashes we need to reach the right parent directory. We can create that string to go up three directories by using the code ("..") x 3 to create the list (".." ".." "..") We then use join to insert a slash between each set of dots. This gives us code very close ...
Sorting Directory Listings with Bash
Recently I've been working on creating an installer for an in-house Cyber Sprocket project using the Nullsoft installer (NSIS). It's an interesting system but it's a bit flaky in a couple areas. One of these areas is in installing and/or removing entire directory structures. It appears that the system is generally designed for explicit definition of all directories and files. While this may often be a perfectly acceptable solution, I wanted a more dynamic system. Because I've been developing the installer externally to the actual development of the project, I don't keep track of what files or directories need to be included, nor do those files and directories remain stable. The NSIS system uses its own scripting language to build the installer. There are lots of various macros out there that do all sorts of things. There is undoubtedly several that do exactly what ...
