bash

At the moment, this is just a dumping ground for useful tidbits I find / need in my daily work. At some point I will get around to organizing and formalizing. Parameter Expansion Bash reference manual Slice a string a="teleport" b=${a:4:7} echo $b > port Replace a portion of a string The pattern is ${parameter/pattern/string} to replace the first occurence of pattern with string or ${parameter//pattern/string} to replace all occurrences....

March 10, 2022 · 1 min · Me

Change your file permissions, baby!

Knowing how to set file permissions is very useful (for a much more thorough primer than I provied here, see this article). Unfortunately, while this is very easy to do, it is even easier to forget the codes used to do so. So here’s how you do it! The easiest (shortest) way to change permissions is using octal syntax. Octal syntax goes like this: chmod <owner><group><others> filename Where <owner>, <group> and <others> stand for the octal numeral pertaining to that user or group....

February 24, 2021 · 1 min · Me

Move and rename all files in a folder

I wanted to move and rename a bunch of excel files in a folder. This is one way to do it from the command line, copying into a directory in the parent folder. I did it this way to be able to rm -r old_folder after copying my files to the new folder. You could modify it to rename them in place, but I’ve accidentally rm -rfed enough things to get nervous doing it that way....

February 17, 2021 · 1 min · Me

Count files by type and directory

Using the command line to count stuff

December 17, 2020 · 5 min · Colin