Linux with Operating System Concepts



Download 5,65 Mb.
Pdf ko'rish
bet36/254
Sana22.07.2022
Hajmi5,65 Mb.
#840170
1   ...   32   33   34   35   36   37   38   39   ...   254
Bog'liq
Linux-with-Operating-System-Concepts-Fox-Richard-CRC-Press-2014

number
overrides 4 as the default sequence length, 
printing sequences of at least 
number
printable characters instead.
3.3.8 Other File Commands of Note
The 
wc
command performs a count of the characters, words, and lines in a text file. The 
number of characters is the same as the file’s byte count (characters stored in ASCII are 
stored in 1 byte apiece). The number of lines is the number of new line (\n) characters found. 
You can control the output through three options, -c or -m for characters only (-m counts 
characters while -c counts bytes), -l for lines only and -w for words only. Additionally, the 
option -L prints the length of the longest line.
You can use wc in a number of different ways. For instance, if you want to quickly count 
the number of entries in a directory, you might use 
ls | wc -l
. If you want to count the 
number of users logged in, you can use 
who | wc -l
.
There are numerous options to create files. Many applications software will create files. 
In Linux, from the command line, you might use a text editor like vi or emacs. You can 
launch either of these with the filename as an argument, as in 
vi newfile.txt
, or you 


92

Linux with Operating System Concepts
can use the “save” command to save the file once you have entered text into the editor. The 
first time you save the file, you will be prompted for a name. We visit vi and emacs later in 
Chapter 5.
The 
touch
command creates an empty text file. The command’s true purpose is to 
modify the access and modification time stamps of a file. However, if the file does not 
currently exist, an empty text file is created. This can be useful if you wish to ensure that 
a file exists which will eventually contain output from some other program such as a shell 
script. Or, touch can be used to start a text file that you will later edit via vi. The options 
-a and -m modify the last access time and date and last modification time and date to the 
current time.
The touch command also has the option -t to specify a new access and/or modification 
date and time. The -t option is followed by the date and time using the format 
[[CC]YY]
MMDDhhmm[.ss]
, which means the current year, month, and date as a 6- or 8-digit number 
(if CC is omitted, the year is implied to be from the current century, and if YY is omitted, 
the year is implied to be this year). The .ss notation permits the seconds if included. For 
instance, 
-t 1112131415.16
would be 2:15.16 p.m. on December 13, 2011. Finally, you 
can use 
-r 
filename
so that the given filename’s time/date is used in place of the current 
time/date.
Another way to create a file is to call upon a Linux command and redirect the output 
from terminal window to a file. For instance,
cat file1.txt file2.txt file3.txt | sort -r 
>
newfile.txt
will combine the three text files, sort the entries in reverse order and store the result to 
newfile.txt. If newfile.txt already exists, it is overwritten. The use of 
>>
will append the 
results to an already existing file, or create the file if it does not already exist.
3.3.9 Hard and Symbolic Links
A directory stores items such as files and subdirectories. In reality, the directory stores 
links to these items. The links are formally known as 
hard links
. Each hard link consists 
of the item’s name and the inode number. The inode number is then used to index into 
or reach the inode itself. Thus, the link provides a pointer to the file. You generally have a 
single link per file. However, you are allowed to create duplicate links to be stored in other 
directories so that accessing the item can be handled more conveniently.
There are two types of links. The hard link is a duplicate of the original link. The 

Download 5,65 Mb.

Do'stlaringiz bilan baham:
1   ...   32   33   34   35   36   37   38   39   ...   254




Ma'lumotlar bazasi mualliflik huquqi bilan himoyalangan ©hozir.org 2024
ma'muriyatiga murojaat qiling

kiriting | ro'yxatdan o'tish
    Bosh sahifa
юртда тантана
Боғда битган
Бугун юртда
Эшитганлар жилманглар
Эшитмадим деманглар
битган бодомлар
Yangiariq tumani
qitish marakazi
Raqamli texnologiyalar
ilishida muhokamadan
tasdiqqa tavsiya
tavsiya etilgan
iqtisodiyot kafedrasi
steiermarkischen landesregierung
asarlaringizni yuboring
o'zingizning asarlaringizni
Iltimos faqat
faqat o'zingizning
steierm rkischen
landesregierung fachabteilung
rkischen landesregierung
hamshira loyihasi
loyihasi mavsum
faolyatining oqibatlari
asosiy adabiyotlar
fakulteti ahborot
ahborot havfsizligi
havfsizligi kafedrasi
fanidan bo’yicha
fakulteti iqtisodiyot
boshqaruv fakulteti
chiqarishda boshqaruv
ishlab chiqarishda
iqtisodiyot fakultet
multiservis tarmoqlari
fanidan asosiy
Uzbek fanidan
mavzulari potok
asosidagi multiservis
'aliyyil a'ziym
billahil 'aliyyil
illaa billahil
quvvata illaa
falah' deganida
Kompyuter savodxonligi
bo’yicha mustaqil
'alal falah'
Hayya 'alal
'alas soloh
Hayya 'alas
mavsum boyicha


yuklab olish