ArtsAutosBooksBusinessEducationEntertainmentFamilyFashionFoodGamesGenderHealthHolidaysHomeHubPagesPersonal FinancePetsPoliticsReligionSportsTechnologyTravel

FreeBSD samba and grep

Updated on May 8, 2009
Samba logo
Samba logo

Quick background

Samba

Samba is the open-source equivalent of windows network neighbourhood. It allows unix based machines to access windows shared files and devices.

grep

grep is a native binary to many *nix based operating systems. It will search for a given expression and return the result.

Quick and Dirty

To quickly search a windows network of a shared resource is very simple using both of these applications.

This example searches the whole 'Network Neighbourhood' for a share named containing the charathers vid

smbtree -bN | grep -iE "vid"

Explaining

Here is the breakdown for it:

smbtree -bN

  • smbtree provides a tree breakdown of resources available on the network.
  • b tells smbtree to query the broadcast and not the master server.
  • N tells smbtree not to ask for a password, So in short this will take out the trying to access a password rotected server

| (pipe)

The | or pipe command is very commonly used. It feeds the output of one application to the input of another

grep -iE "vid"

  • grep command to search and return the output
  • i - makes the search case insensative
  • E - extended regular expresion
  • "vid" - the text to search for like in video

From here on you can get more creative and combine various search criteria

smbtree -bN | grep --color=auto -iE "vid|mov|ser|mentries"

Ok so here we add the following

  • --color=auto - this will just color highlight your results
  • "vid|mov|ser|mentry" - here we add another | (pipe). BUT this is a regular expression (regex) pipe, it means OR, so search for "My Videos" OR "Shared Movies" OR "House Series" OR "Discovery documentries"

Hope this give you some ideas and tips on quick and easy searching.

About the tutorial

The contents of this does not delfe into the deep and inner workings of the relevant applications used. This provides working examples and brief explanations about the usage. For more indepth detail see the relevant applications websites

Comments

    0 of 8192 characters used
    Post Comment

    No comments yet.

    Click to Rate This Article