Tuesday, March 15, 2011

Most needed yet least known commands

  1. dir /S *.ext
    • Find a file or folder in Windows Command Prompt
  2. dir /X
  3. mklink <linkName> <target>
    • It is used to create a symbolic link in Windows Command Prompt. It is natively available in Windows Vista/2008+ (not in PowerShell or as an executable).
  4. find ./ -name *.ext
    • Find a file or folder in Unix Shell
  5. del /s /q targetFolder\*
    • Remove all the files recursively from sub-folder as well as target folder in Windows Command Prompt
  6. rmdir /s /q targetFolder
    • Remove all the files & folder recursively from sub-folder and at the end remove the target folder as well in Windows Command Prompt
  7. grep -lir "some text" *
    • List all the files where "some text" is found, ignore case and search sub-directories recursively.
  8. grep -lr "bulkInsert" ~/ --include "*.js"
    • search recursively through a specified location (in this case its ~/ which is the home directory) for any files that are of type .js and contain the string bulkInsert, pretty nice way to find lost things.
  9. combine find and grep
    1. ignore certain folders
    2. look in package.json only
    3. find case-insensitve matches to the word: commit
  10. Lock a Mac running on Lion OS X
    • Excerpt: "To lock your screen quickly with fast user switching enabled, choose Login Window from the menu with your user name. Your applications will remain open and undisturbed, but your computer islocked." You will find the "Login Window" immediately to the left of the Search (spotlight) Icon on the top right. Its your name that's written to the left of this search icon and this name can be clicked to reveal the "Login Window" option. And that's it, clicking it locks your mac.
    • Shift-Command-Option-Q
  11. diff -y /path/to/file1 path/to/file2
    • "Lines unique to the first file are displayed with a greater than sign (>) at their start, while lines unique to the second file start with a less than sign (<). You might also consider using the -y option to display the the two files in two columns..." (Excerpt source)


Post a Comment