Tag Archives: Command line

Unix: Recursive search for text in files

Keep forgetting how to do this, so here it is. How to do a quick and simple, recursive search for text using grep. Hint: It’s very simple.

$ grep -rl "some text" .

That’s all there is to it! grep is the command, r makes the search recursive (i.e. in the target folder and all its sub-folders), l means it will list the name of all the files where it finds the text, "some text" is the string to search for, and finally, the dot at the end means to start the search in the current directory. And just to clarify, this searches for text inside of files, in the content of the files; not the filenames.

There, now I know where to find it when I forget it next time. And perhaps I have helped someone else too 🙂

Good night!

How to make the Bash command prompt more useful

Was on a Linux box today and I found the command prompt rather useless. It looked like this:

-bash-3.2$

I know I’m using bash, and I don’t really care about the version. Or that I’m using bash actually… But anyways, to make it more useful you can run this:

$ PS1="\u@\h:\w$ "

You will then get a prompt which contains your username, hostname and current working directory. Much more useful in my opinion. If you have a different opinion, please share 🙂

You can find more stuff to put in your prompt by reading the prompting section of the bash man page.

How to enable verbose booting in Mac OS X

I’m a curious guy, so I wanted to see if there was anything interesting happening behind the Apple logo when the Mac I use at work boots up.

Turned out it was quite simple to enable and disable this feature. To enable it, just open up a Terminal and run the following command:

$ sudo nvram boot-args="-v"

When you reboot the next time, you will see all the fun stuff happening during the boot up. If you get tired of it, you can disable it again by running:

$ sudo nvram boot-args=

That’s it!

Disappearing color labels in Mac OS X

Had a tiny fight with Mac OS X the other day, like I often do. This time it was color labels. You probably know (if you have used Mac OS X at all) that you can color label your files. You simply right-click them in the Finder and select a color label.

This can be quite a handy feature, but not so much when it doesn’t work. My problem was that I would give a bunch of files color labels, but then shortly after that the label simply disappeared. I could look at the file in the Finder, it had its label, I’d click on it, and the label disappeared. In fact the color label was already gone, it was just that the Finder is kind of slow to update itself… O’ how I miss F5 sometimes…

Continue reading Disappearing color labels in Mac OS X

Helpful Unix and Mac commands

I am for the most part a Windows user. I was kind of moving towards Linux, Ubuntu in particular, but that ship pretty much sailed when I got my hands on Windows 7. Awesome, awesome operating system. But, I still have to use some Unix and Mac systems once in a while. And then there are certain commands that I often use, but always forget since it usually goes a bit of time between times I do it. So, what follows is basically just a list of commands that I keep forgetting, but keep having to look up again.

Continue reading Helpful Unix and Mac commands