Text Completion Feature in Dos and Unix

There are some features in Unix that are very powerful, especially the commands. I am very much interested in these commands and today want to share one such general command which may be of use many times, and not just for geeks!. We have also included the corresponding DOS command, as our analytics stats show that most of our readers are yet using windows!

Text Completion Feature ?
Text completion is a feature built into some Unix shells that allows you to type part of a filename or directory name and press a key to fill out the rest.

DOS:- Text Completion Feature
In DOS we make use of tab button.
Ex:-

c:\>cd Doc[tab]

this will automatically take the full folder name as

c:\>cd “Documents and Settings”

[Test this–> C:\>cd Doc (now press the tab button)].

If you have multiple files in the same folder, whose name starts with “D”, then you can navigate between them by pressing tab key multiple times.
cmd-text-completion-feature-UNIX-DOS
Many times we struggle to type the correct folder name and most of the times(when names are too long) end up typing wrongly. This can be avoided by knowing these simple yet powerful commands. Powerful because, we can use this feature with other commands to get some amazing results.

Unix:- Text Completion Feature

When you are in the command mode:-
Ex:-

$ar [tab]

In the above example, if a directory contains 4 folders or sub-directories by name 1. archive 2. archana 3. Sagar 4. archimedes, then you have to press the tab key two times, to get the list of all the sub-folders whose name starts with ar.

$ archive/ archana/ archimedes/

If there is only one sub-folder whose name starts with ar, then when you press the tab key once, the remaining letters of the word appears automatically.

In vi Editor:
When you are typing something in the vi editor, you can make use of this text completion feature. When you press [ctrl-p] after typing one or two letters, the text will auto complete. To autocomplete, Unix shell will look into the previously typed text in the same file and then fill the word accordingly. If there are more than one word which starts with the same letter(in the same file), then you can navigate between these words by using [Ctrl-n] option.

Some UNIX flavor does not support “Text-Completion-Feature”, and sh shall also does not support this feature. And some UNIX flavor may support this feature, but may have different keys to use.

Share your tips, tricks and hacks about commands in below comment section. By sharing our knowledge, we endup learning more..

Use Notepad(.bat) to Shutdown your PC(Windows Only)

Today we shall see some tricks to shutdown your computer by clicking on a file that you will be creating, using notepad or any other text editor.

Open a notepad. Save it as ILOVEU.bat (any name with file extension .bat), now copy and paste below codes into the notepad and save it again..

@echo off
c:
cls
echo hey wana be friends?
pause
echo did u say no???????????
pause
echo u r hacked
echo Type some message!
shutdown -s -t 30 -c “f*ck off”

As soon as someone clicks on this .bat file, these below popup’s will be displayed..

dos-prompt-program
shut-down-bat

Other options that you can use along with the shutdown command are :
To shutdown computer -> “shutdown -s”
To restart computer -> “shutdown -r”
To logoff computer -> “shutdown -l”
To halt a restart/shutdown –> “shutdown -a”
You can use all these commands directly in DOS prompt or in a script.

You can add some more features to this notepad by reading the help topics in your dos prompt.

Just type help after you enter the dos prompt ( C:\>help ).

Not recommended:
If you remove the pause statement from above code and put this file in the startup( C:\Documents and Settings\All Users\Start Menu\Programs\Startup or C:\Documents and Settings\current user\Start Menu\Programs\Startup ) folder, then your computer will shutdown(automatically) when this file loads at startup.

This article is written to teach you the method to troubleshoot your computer yourself, if someone uses this technique and creates problem in your computer.

Solution:-
Just enter into the dos mode(pre-boot mode, using any bootable disks), and search for any file with .bat extension in Startup folder. And if found, just delete it and restart your computer and it will work normally 🙂

These type of files are being sent by some anonymous people in IMs and also as attachments in emails. This could create some irritating problem and you may loose some data on your computer that you have not saved. So be careful when you get a file with .bat file extension. Better not to click on it.