All Windows command line commands in one place. Display line numbers in a file

8.4. Displaying the contents of a file on the screen - the TYPE command

Command specification:

TYPE [n:][route]filename[.type]

The characters * and ? in the file name. not allowed.

The TYPE command is used to display the contents of a file on the screen. The name may be preceded by a prefix indicating the location of the file. Of course, with the help of the TYPE command, you can see meaningful text on the screen only if the file contains

contains information encoded in accordance with the ASCII standard or its modification. Each byte of stored information must be a letter, number, or character that can be represented on the screen.

C:\>type prog1.asm

C:\>type\work\document.txt

8.5. Display directory - DIR command

Command specification:

DIR [n:][filename[.type]]

The command gives information about directory elements (files and subdirectories) - their names, extensions, length in bytes (for files), subdirectory sign

(for subdirectories), time and date of creation, as well as the label of the disk and the amount of free space on it in bytes.

The /P option specifies a "paged" output of a directory the size of a screen.

The /W option is used to compactly display a directory.

The simplest use of the DIR command without options will display the current directory. The image on the screen takes, for example, the following form:

Volume in drive C is TOM1

Directory of C:\

CONFIG SYS 118 6-03-88 11:42p

AUTOEXEC BAT 994 7-20-88 12:59p

COMMAND COM 22042 8-14-88 8:00p

SYS

5-19-88 2:19 p.m.

EXE

2-25-88 4:44 p.m.

ABC

5-29-88 9:47a

DOC

4-30-88 9:43a

WORK

1-20-88 4:44a

8 File(s) 65344 bytes free

The text displayed on the screen says:

Drive C: labeled TOM1;

There are 3 regular files registered in the root directory (CONFIG.SYS, AUTOEXEC.BAT and COMMAND.COM) and 5 subdirectories.

All files taken together occupy about 300 disk space.

KB. This follows from the fact that the total volume of the disk is 360 KB, and a little more than 65 KB remained free.

To view the DOC subdirectory, it is enough to issue the DIR command with the parameter - the name of the subdirectory:

In this subdirectory, at the beginning of the issued table, 2 lines of a special form appeared:

.

4-30-88 9:43a

..

4-30-88 9:43a

These lines indicate that the given directory is a subordinate directory, along with the date and time it was created.

The DIR command parameter can be any route pointing to the root or subdirectory of any level located on any disk. Let's look at a few examples:

C:\>dir doc\abc

This command will return the ABC subdirectory of the DOC.

C:\DOC\ABC>dir \work

Here, the current second-level subdirectory is DOC\ABC, but the route says to return the WORK directory, starting from the root directory.

C:\WORK>dir\

This command asks for the root directory of the C: drive.

Here, the current directory is the root directory of drive A:, but the route points to the root directory of drive C:.

Thus, no matter what current directory the system is set to, the user has the opportunity to view any file directory of interest to him by specifying the appropriate route as a parameter of the DIR command.

In addition to specifying a path, the DIR command option often contains a pattern of filenames that allows you to select a specific group of files.

Select from subdirectory DOC files TXT type. You can specify the DIR command with the pattern *.TXT. The command looks like:

C:\>dir doc\*.txt

The template can also be specified without the route prefix; then a group of files in the current directory is selected.

The DIR command, in any of its variations, does not change directories, it only lists their contents.

It often happens that the screen is "not enough" to display all the lines of the catalog. To be able to carefully review all the lines, you can give the special /P indicator at the end of the command text. In this case, after issuing the first 23 lines of the directory, the system will interrupt the issuance and wait until the user presses any key.

Another way of issuing is provided by the /W pointer. When it is set, the system issues only the names and types of files, without other attributes. In this case, the output occurs not in a column, but in rows. Thanks to this method, much more space is placed on the screen.

more filenames than the normal format, although they are less readable.

Examples of commands with pointers:

C:\>dir doc\abc /w

8.6. Creating a new directory - MKDIR (MD) commands

Command specification:

MD [n:]route / MKDIR [n:]route

Creating a new subdirectory can be done in any current directory.

For example, in the current WORK subdirectory, you need to create a PRO subdirectory.

Let's use the MD command to create a PRO subdirectory in WORK:

C:\WORK>mdpro

After that, in the WORK directory will appear new line type:

PRO

7-05-88 5:26 p.m.

The newly created subdirectory can be populated with files. As long as at least one file is registered in the subdirectory, it cannot be deleted. Even if you try to do this, the system will not perform this operation.

A file that is a directory takes up 4 KB of memory on external media, so creating new directories is not a harmless operation in terms of wasting memory on external media.

8.7. Removing Subdirectories - RMDIR (RD) Command

Command specification:

RD [n:]route / RMDIR [n:]route

The directory must be empty, i.e. contain only "."

The current and root directories cannot be deleted.

Removing a subdirectory is done with the RD command. In this case, you can delete in any directory.

C:\WORK>rdpro

C:\DOC>rd\work\pro

The first command removes the PRO subdirectory from the current WORK directory.

The second command removes the same subdirectory, although the current directory is DOC.

8.8. Change current directory - CHDIR command (CD)

Command specification:

CD [n:][route] / CHDIR [n:][route]

Changes the current directory on the specified or current drive. Changing the current directory is a commonly used operation.

C:\>cddoc\abc

The transition from the root directory C:\ to the subdirectory log of the second level \doc\abc is carried out.

This operation can be carried out with two commands

C:\DOC>cd abc

Returning from the subordinate directory one level up is carried out by the command:

To return to the most upper level the command is given:

It should be noted that the characters ".." and "\" can be included in the designation of routes when it is required to specify complex transitions between subordinate directories. For example, route ..\PRO means "go up one level and then down into the PRO subdirectory", and route ..\.. means "go up two levels". Such route designations may appear in DIR, CD, RD, PATH, COPY, DEL, and other commands, but

they must be used with great care, especially in delete commands.

LIST OF USED LITERATURE

1. Reference Guide for the IBM PC. methodical

materials. Part 2. CCI “SPHERE”. M. 1991

2. Saveliev A.Ya., Sazonov B.A., Lukyanov S.E. "Perso-

a personal computer for everyone". Book 1.

M., HIGH SCHOOL, 1991

3. Bryabrin V.M. “ Software personal

COMPUTER". M. "NAUKA", 1990

4. Figurnov V.E. “IBM PC for User”

Ufa, NPO "Informatics and Computers", 1993

Makeevka Economics and Humanities Institute.

Applied Mathematics

and information

technologies

L A B O R A T O R N A Y R A B O T A No. 2

On the topic: Working with commands of the MS-DOS operating system

Completed:

1st year student

Full-time - correspondence department

Faculty: Law and Psychology

Command line or as it is also called cmd in the operating room Windows system 8 is the same as in the younger versions of Windows7, Windows Vista, Windows xp, it follows that the same commands work the same in all versions.

So let's first figure out how to start the command line. To do this, you must have a working computer with an operating system.

Some commands if you are working through account regular user there may not be enough rights to execute for security purposes, so always run the command prompt with administrator rights. There are 2 ways to run the command line:

In the window that appears, write cmd, click OK.

A command prompt window will open with a black background.

2) More fast way: through the Win + R hotkeys, here we also write cmd in the window that appears, press ok.

In windows 8, you can only use 2 ways, since there is no start menu. Let's write our first help command which will list all available commands with brief explanations.

List of all existing Windows command line commands:

ASSOC Printing to the screen or modifying file name extension mappings.
ATTRIB View and modify file properties.
BREAK Locks or unlocks extended CTRL+C handling on a DOS system.
BCDEDIT Sets properties in the boot database that allow you to control the bootstrap.
CACLS Displays data and modifies file access control lists (ACLs).
CALL Calls one batch file from another and can also pass input arguments.
CD
CHCP Output or set encoding.
CHDIR Displays the title or moves to another folder.
CHKDSK Diagnostics of the drive for errors.
CHKNTFS Shows or changes the drive diagnostics during boot.
CLSO cleaning the display of all characters.
cmd Runs a command line program Windows strings. You can run an infinite number of them on one computer. They will work independently of each other.
COLOR Changes and sets the main background of the window and the fonts themselves.
COMP Shows the differences and compares the contents of two files.
COMPACT Changes and shows file compression in NTFS.
CONVERT Changes FAT disk volumes to NTFS. The current drive cannot be changed.
COPY Creates a copy of a file or files and places them in the specified location.
DATE Shows or sets the current date.
DEL Destroys one or more files at once.
DIR Shows the names of files and folders with their creation date, located in the current folder or specified in the folder options.
DISKCOMP Compares and shows the differences between 2 floppy drives.
DISKCOPY Creates a copy of the contents of one floppy drive to another.
DISKPART Shows and changes the properties of a disk partition.
DOSKEY Modifies and re-invokes command lines; creates macros.
DRIVERQUERY Displays information about the "state of affairs" and attributes of the device driver.
ECHO Displays textual information and changes the display mode of commands on the screen.
ENDLOCAL Ends environment localization for a batch file.
ERASE Destroys a file or files.
EXIT Terminates a command line program
FC Shows differences between two files or two sets of files and compares them
FIND Searches for a text string in files or in a single file.
FINDSTR Advanced Search text strings in files.
FOR Cycle. Repeats the execution of the same command the specified number of times
FORMAT Formatting the drive for Windows.
FSUTIL Displays and sets file system attributes.
FTYPE Provides the ability to edit and view file types, which are primarily used in file name extension matching.
GOTO Transfers control to another specified command.
GPRESULT Displays information about group policy for a computer or user.
GRAFTABL Gives Windows feature show extended character set in graphics mode.
HELP Displays all data about existing Windows commands.
ICACLS Shows, modifies, archives or restores ACLs for files and folders.
IF Executes commands based on a given condition.
LABEL Creates, modifies, and destroys volume labels for drives.
MD Creates an empty directory.
MKDIR Creates an empty directory.
MKLINK Creates symbolic and hard links
MODE Configures system devices.
MORE Sequentially displays information in blocks of one screen size.
MOVE Moves files from one location to another.
OPENFILES Shows files that are open on shared folder remote user.
PATH Outputs or sets full path to executable files.
PAUSE Terminates the execution of command line commands and prints informative text.
POPD Restores the previous active folder value that was saved with the PUSHD command.
PRINT Prints the contents of a text file.
PROMPT Modifies the prompt on the Windows command line.
PUSHD Saves the active folder value and navigates to another folder.
RD Destroys a directory.
RECOVER Resurrects readable data from a bad or damaged hard drive.
REM Puts comments in batch files and the CONFIG.SYS file.
REN Changes the name of both files and folders.
RENAME Similar team REN.
REPLACE Swaps files.
RMDIR Destroys a directory.
ROBOCOPY Advanced tool for copying files and entire folders
SET Shows, installs and destroys Environment Variables Windows.
SETLOCAL Localizes environment changes in a batch file.
SC Allows you to work with services
SCHTASKS Allows you to run any program and sequentially execute the necessary commands according to a given plan
SHIFT Changes the position (shift) of the inline parameters for the batch file.
SHUTDOWN Shuts down the computer.
SORT Sorts the input according to the given parameters.
START Launches a program or command in a new window.
SUBST Assigns a drive name to the specified path.
SYSTEMINFO Displays information about the operating system and configuration of the computer.
TASKLIST Shows a list of all running processes with their IDs.
TASKKILL“Kills” or stops the process.
TIME Sets and displays the system time.
TITLE Sets the name of the window for the current session of the CMD.EXE command line interpreter
TREE Displays the directories of the drive in a convenient visual form.
TYPE Displays the contents of text files.
VER Displays brief information about the Windows version.
VERIFY Checks for file write errors on the drive.
VOL Displays labels and serial number drive volumes.
XCOPY Creates a copy of files.
WMIC Displays WMI on the command line.

The cat command (short for " concatenate") is one of the most commonly used command in Linux Unix-like operating systems. The cat command allows you to create one or more files, view the contents of files, concatenate files, and redirect output to the terminal or files. In this article, we will find out how convenient it is to use cat commands with examples in Linux.

General Syntax

cat...

1. Show file content

The example below shows what is contained in the file. /etc/passwd.

# cat /etc/passwd root:x:0:0:root:/root:/bin/bash bin:x:1:1:bin:/bin:/sbin/nologin narad:x:500:500::/ home/narad:/bin/bash

2. View the capacity of multiple files in the terminal

The example below shows how to display content in test and test1 file in terminal.

# cat test test1 Hello everybody Hi world,

3. Create a file with the cat command

We will create a file named test2

#cat >test2

While waiting for input from the user, type the required text and press ctrl+d(press and hold the key ctrl and type " D") to exit. The text will be written in test2 file. You can see the contents of the files with the following command cat.

# cat test2 hello everyone, how do you do?

4. Use cat command with more & less options

If the file has a lot of information content, then it will not fit in the output slot and the screen will scroll up very quickly. In such a case, we can use the more & less options with the cat command as shown above.

# cat song.txt | more # cat song.txt | less

5. Display line numbers in a file

With option -n you can see the line numbers of the file song.txt at the exit terminal.

# cat -n song.txt 1 "Heal The World" 2 There's A Place In 3 Your Heart 4 And I Know That It Is Love 5 And This Place Could 6 Be Much 7 Brighter Than Tomorrow 8 And If You Really Try 9 You "ll Find There" s No Need 10 To Cry 11 In This Place You "ll Feel 12 There" s No Hurt Or Sorrow

6. Display $ at the end of the file

In the example below, you can see with the option -e, what " $ " appears at the end of a line, and also when there is a gap between paragraphs. This option is useful for merging multiple lines into one line.

# cat -e test hello everyone, how do you do?$ $ Hey, am fine.$ How"s your training going on?$ $

7. Show Tab Line Separation in File

In the output below, we see how the space TAB filled with " ^I".

# cat -T test hello ^Ieveryone, how do you do? Hey, ^Iam fine. ^I^IHow"s your training ^Igoing on? Let"s do ^Isome practice in Linux.

8.Simultaneous display of multiple files

In the example below we have three files test, test1 and test2 and the ability to view the contents of those files, as shown above. We have to split each file with ; (semicolon).

#cattest; cat test1; cat test2 This is test file This is test1 file. This is test2 file.

9. Use stdout with the redirect operator

We can redirect standard output to a file in new file another existing file with " > "(more). Caution, content from test1 will be overwritten in the contents of the file test.

# cat test > test1

10. Adding Standard Exit with Redirect Operator

Appending to an existing file with " >> "(double more). Here the contents in the file test will be added at the end of the file test1.

# cat test >> test1

11. Redirecting standard input with the redirect operator

When you use redirect with stdin" < "(character less), it uses the filename test2 as the input for the command and the output will be shown in the terminal.

# cat< test2 This is test2 file.

12. Redirecting the contents of multiple files into a single file

This creates a file named test3 and all outgoing will be redirected to the newly created file.

# cat test test1 test2 > test3

13. Sort the contents of multiple files into one file

This creates the file test4 and the output of the cat command through the pipeline for sorting; the result will be redirected to the newly created file.

# cat test test1 test2 test3 | sort > test4



Loading...
Top