Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

Development Tools Introduction to the Terminal The Command Shell Command Options

David McGarvey
seal-mask
.a{fill-rule:evenodd;}techdegree seal-36
David McGarvey
Full Stack JavaScript Techdegree Graduate 27,424 Points

'-n' command option doesn't respond as intended while using it in the Terminal.

First off, great course! So in the Terminal, the output I get when I type this at the prompt: cat -n bird.txt cart.txt statue.txt is slightly different than when I type the same in the workspaces command line prompt. I get back the content numbered, but all numbers are #1, as opposed to the ascending numbers I should get.

I get:

    1    There is a bird here, looking up at the statue with interest.
    1    A stand selling hot dogs and bottles of diet cola.
    1    A statue of a hunter standing over a dead bear. Creepy.

When I should be getting:

    1    There is a bird here, looking up at the statue with interest.
    2    A stand selling hot dogs and bottles of diet cola.
    3    A statue of a hunter standing over a dead bear. Creepy.

I'm guessing this has something to do with the versioning of Python on my machine. It's default is still Python 2 but I use Anaconda to be able to use Python 3 in the Terminal. Any ideas as to what is happening? Thanks in advance!

PS. Also, when I try to use the long form command of ls --all, I get an unusual error back:

ls: illegal option -- - 
usage: ls [-ABCFGHLOPRSTUWabcdefghiklmnopqrstuwx1] [file...]

This has to be related, right?

4 Answers

Jay McGavren
STAFF
Jay McGavren
Treehouse Teacher

Mac OS is based on BSD, and so has the BSD versions of cat, ls, and other tools. Although the commands work very similarly, there may be small differences. You can learn the details of the BSD versions using man.

Many developers prefer to switch out the BSD tools for their GNU versions (so they work just like they do on Linux). You can learn how to do so here.

I'm on a Mac 10.14.1 and get the same results as you

Dave StSomeWhere
Dave StSomeWhere
19,821 Points

Interesting, maybe you're running a different shell or have different settings on MAC's.

Code works as desired/expected on my Ubuntu 18.04 running the bash shell.

Also, the workspaces console is running the bash shell on Ubuntu 16.04.

Maybe someone has some insight as to the differences with the OS X terminal - sure seems like most people are using MACs.