Birmingham mumbai



Download 15,21 Mb.
Pdf ko'rish
bet182/482
Sana13.01.2022
Hajmi15,21 Mb.
#355107
1   ...   178   179   180   181   182   183   184   185   ...   482
Bog'liq
Mastering Ubuntu Server Gain expertise in the art of deploying, configuring, managing, and troubleshooting Ubuntu Server by Jay LaCroix (z-lib.org)

[
 133 
]
Notice that I added a 
1
 right before the 
greater-than
 symbol. Standard output is 
designated by a file descriptor of 1. So, with that command, I'm specifically saying 
that I want to redirect standard output, and 
only
 standard output, into the file. 
Standard output is implied, so I didn't need to include the 
1
. That's why simply using 
the 
greater-than
 symbol works for redirecting standard output to a file.
Standard input also has a file descriptor, which is 0. Standard input is how 
commands receive data. Essentially, commands that accept input from the user do so 
by accepting 
stdin
. Standard input is a bit more challenging to show in an example, 
but the following works:
cat /var/log/syslog | grep -i
With that command, I'm grabbing the contents of the 
/var/log/syslog
 file and 
piping that into the 
grep
 command, which allows me to display only the lines that 
include a specific term. No two 
syslog
 files will be the same, since every server can 
be configured uniquely. But if you're attempting to investigate a specific application 
or service, you can 
grep
 the log for keywords you think might be appropriate. If 
you include the 
-i
 option, then 
grep
 will perform a search that's case-insensitive. In 
this example, the output of the 
cat
 command becomes standard input to the 
grep
 
command. This command can be executed with any search term of your choice.
I could have also run:
cat < /var/log/syslog | grep Network
In that example, I'm using the 
less-than
 symbol to redirect the contents of 
/var/
log/syslog
 to be standard input to the 
cat
 command. The 
cat
 command normally 
prints whatever text is fed to it to the screen as standard output, but instead, I'm 
using the pipe symbol, 
|
, to grab that output and use it as standard input to the 
grep
 
command.
If you want to append a file rather than completely overwrite it, 
you can use two 
greater-than
 symbols (
>>
) to append, rather than 
overwrite. For example, the following command will add the 
contents of the 
syslog
 file to the end of the 
logfile.txt
 file, 
rather than overwrite the entire file:
cat /var/log/syslog >> ~/logfile.txt


Managing Files and Directories

Download 15,21 Mb.

Do'stlaringiz bilan baham:
1   ...   178   179   180   181   182   183   184   185   ...   482




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