in mac terminal, how to find a file in the current directory or subdirectories?

29,101

Solution 1

find . -iname something.py

(the '.' specifies the current directory). -iname makes find check the next argument against filenames, case-insensitively, which is the norm for Mac OS filesystems.

Solution 2

Please don't mix up "Terminal Commands" with the shell commands or the command line.

This is a terminal: http://en.wikipedia.org/wiki/File:Terminal-dec-vt100.jpg

Specifically that is a DEC VT-100, possibly the most used type of terminal for UNIX back in the days UNIX was being developed. There were a large number of different kinds of terminals around until the mid-1980's or so. All these pieces of hardware could do was display characters on the screen, move the cursor around the screen and some other minor functions like clear to end of line, or scroll the display up 1 line.

While that device may look like an early PC to you, its not a PC. The only thing this device can do is display characters of text on its screen. and it makes no decisions itself about what characters go on the screen, or where they go on the screen. It has be commanded what to do by a computer, usually a multi-user, Timesharing computer.

Despite these limitations, These Terminals are what the users used to do everything on UNIX, programming, running applications, playing games (yes, games), Email, IRC, Chat etc... But All the Terminal could do was display characters on its screen, so how could you run an editor in it?

You couldn't, and you didn't. The editor ran inside a multi-user, timesharing computer, lets say a PDP-10, which might have had 30 or 40 Terminals connected to it. So there could be 30 or 40 users all sharing the same computer at the same time. They might even have all been editing at the same time. But How?

Each user had their own processes. A User who was editing ran their editing session inside the PDP10, and the editor program inside the PDP10 would send ""Terminal Commands"** to the terminal to show things on the screen of the Terminal.

Here are some actual Terminal Commands for a vt100:

[ 1 m sending these three characters to a vt100 would put the terminal in BOLD mode. all text displayed after that would appear as bolded text, until another command is sent to the terminal to turn off bold mode.

[ ; H Put the cursor at position X,Y on the screen.

[ 0 K Clear line from current cursor position to end of line

[ 1 K Clear line from beginning to current cursor position

[ 2 K Clear whole line (cursor position unchanged)

[ 3 0 m sending these three characters would cause the terminal to set the background color to black

Eventually hardware terminals dwindled completely away. But we still needed a terminal in order to be the input and display device for those thousands and thousands of programs that run on UNIX (and now, Linux of course.) Thats where X-windows Terminal Emulators came into being. These are little graphical programs that emulate what would happen on a real hardware terminal when running a program. They open a window that looks and behaves just like a real terminal (or almost).

The Terminal emulators include, X-term, Gnome Terminal, Konsole and others. Remember - None of these are terminals. They are Terminal emulators. If you send them Terminal Commands, like the ones shown above, you will be directly controlling what the Terminal emulation screen shows.

Of course sending escape chars and control chars is a pain, so naturally the UNIX developers made some tools to make things easier. Terminfo, termio, curses, and tput are all special utilities used to make the sending of Terminal commands to your terminal emulators much easier. Most people find tput to be the most useful of these choices. So when you are on the Bash command line, typing in commands, cat, awk, grep etc..., please remember that you're not running "Terminal commands", you're running shell commands, or command line commands. :)

Share:
29,101

Related videos on Youtube

user27449
Author by

user27449

Updated on September 17, 2022

Comments

  • user27449
    user27449 almost 2 years

    in mac terminal, how to find a file in the current directory or subdirectories?

    the filename is: 'something.py'

  • churnd
    churnd about 14 years
    Find is a good choice for any unix platform. If you want something OS X specific, try mdfind, which is basically the CLI version of Spotlight.
  • Kyle Jones
    Kyle Jones over 11 years
    Informative, but you didn't get around to answering the question.
  • Eric
    Eric over 2 years
    No reasonable person would confuse "terminal commands" with a mainframe terminal or terminal emulator. The term "terminal commands" is colloquially understood to mean shell/bash commands.