UNIX and Linux File Processing

UNIX/Linux File Processing

UNIX and Linux File Processing

Based on the approach that files should be treated as nothing more than character sequences Because you can directly access each character, you can perform a range of editing tasks – this offers flexibility in terms of file manipulation

Reviewing UNIX/Linux File Types
Regular files, also known as ordinary files
Create information that you maintain and manipulate, and include ASCII and binary files
Directories
System files for maintaining file system structure
Special files
Character special files relate to serial I/O devices
Block special files relate to devices such as disks

Understanding File Structures
Files can be structured in many ways depending on the kind of data they store
UNIX/Linux store data, such as letters and product records, as flat ASCII files
Three kinds of regular files are
Unstructured ASCII character
Unstructured ASCII records
Unstructured ASCII trees

Processing Files
UNIX/Linux processes commands by receiving input from a standard input device (e.g. keyboard) and sending it to a standard output device (e.g. monitor) System administrators and programmers refer to standard input as stdin, standard output as stdout When UNIX/Linux detect errors, they send data to standard error (stderr, the monitor)

LIRE AUSSI :  Cours UNIX les commandes et organisation des fichiers

Using Input and Error Redirection
You can use redirection operators to retrieve input from something other than the standard input device and send output to something other than the standard output device
Examples of redirection
Redirect the ls command output to a file, instead of to the monitor (or screen)
Redirect a program that receives input from the keyboard to receive input from a file instead
Redirect error messages to files, instead of to the screen by default

Manipulating Files
When you manipulate files, you work with the files themselves, as well as their contents
Create files using output redirection
cat command – concatenate text via output redirection
without a command – > filename
touch command – creates empty files
Delete files when no longer needed
rm command – permanently removes a file or an empty directory
The -r option of the rm command will remove a directory and everything it contains
Copy files as a means of back-up or as a means to assist with new file creation
cp command – copies the file(s) specified by the source path to the location specified by the destination path

Cours gratuitTélécharger le cours complet

Télécharger aussi :

Laisser un commentaire

Votre adresse e-mail ne sera pas publiée. Les champs obligatoires sont indiqués avec *