linux怎么查看本机内存大小
230
2022-09-17
shell输入输出
重定向字符>和>>
>符号可以将前面命令的结果重定向到符号后面指定的地方,如:
~/Desktop$ ls > hello.txt~/Desktop$ cat hello.txtaAIDLEXampleBookcEMASEnglishHouseGithubSourcegit常用命令.txtGTK+学习.txthello.txt...
如上面将ls的结果重定向输出到一个文件hello.txt上,如果hello.txt一开始不存在,就会创建一个新的,如果存在,就会将hello.txt的内容覆盖掉,如果不想被覆盖掉,可以使用>>重定向符号。它会将内容追加到文件末尾,如:
~/Desktop$ ls >> hello.txt
管道(|)
管道可将一个命令的执行结果输出到另一个命令,让另一个命令来处理结果,如:
~/Desktop$ head /proc/cpuinfo | tr a-z A-ZPROCESSOR : 0VENDOR_ID : GENUINEINTELCPU FAMILY : 6MODEL : 78MODEL NAME : INTEL(R) CORE(TM) I5-6200U CPU @ 2.30GHZSTEPPING : 3MICROCODE : 0XD6CPU MHZ : 624.617CACHE SIZE : 3072 KBPHYSICAL ID : 0
首先使用head命令显示/proc/cpuinfo文件的前10行(默认是10行),然后这10行数据通过管道(|)传递到tr命令来处理,tr命令将完成小写转大写的功能,最后显示到终端上,默认是显示到终端上,我们也可以将结果重定向到某个文件,如:
~/Desktop$ head /proc/cpuinfo | tr a-z A-Z > hell.txt
head与tail命令
head显示文件的前n行,显示是前10行:
~/Desktop$ head /proc/cpuinfoprocessor : 0vendor_id : GenuineIntelcpu family : 6model : 78model name : Intel(R) Core(TM) i5-6200U CPU @ 2.30GHzstepping : 3microcode : 0xd6cpu MHz : 616.761cache size : 3072 KBphysical id : 0
tail默认显示最后10行:
~/Desktop$ tail /proc/cpuinfocpuid level : 22wp : yesflags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe syscall nx pdpe1gb rdtscp lm constant_tsc art arch_perfmon pebs bts rep_good nopl xtopology nonstop_tsc cpuid aperfmperf tsc_known_freq pni pclmulqdq dtes64 monitor ds_cpl vmx est tm2 ssse3 sdbg fma cx16 xtpr pdcm pcid sse4_1 sse4_2 x2apic movbe popcnt tsc_deadline_timer aes xsave avx f16c rdrand lahf_lm abm 3dnowprefetch cpuid_fault epb invpcid_single pti ssbd ibrs ibpb stibp tpr_shadow vnmi flexpriority ept vpid ept_ad fsgsbase tsc_adjust bmi1 avx2 smep bmi2 erms invpcid mpx rdseed adx smap clflushopt intel_pt xsaveopt xsavec xgetbv1 xsaves dtherm ida arat pln pts hwp hwp_notify hwp_act_window hwp_epp md_clear flush_l1dbugs : cpu_meltdown spectre_v1 spectre_v2 spec_store_bypass l1tf mds swapgs itlb_multihitbogomips : 4800.00clflush size : 64cache_alignment : 64address sizes : 39 bits physical,
sort排序
按字母顺序进行快速排序。
~/Desktop$ sort hello.txtaAIDLEXampleBookcEMASEnglishHouseGithubSourcegit常用命令.txtGTK+学习.txthello.txtMOK.derMOK.priv...
file显示文件格式信息
~/Desktop$ file hello.txthello.txt: UTF-8 Unicode text
find与locate查找命令
locate在系统创建的文件索引中查找文件,这个索引由操作系统周期性更新,查找速度比find要快,如:
~/Desktop$ locate stdio.h.../usr/include/stdio.h/usr/include/c++/7/tr1/stdio.h/usr/include/glib-2.0/glib/gstdio.h/usr/include/unicode/ustdio.h/usr/include/x86_64-linux-gnu/bits/stdio.h/usr/lib/x86_64-linux-gnu/perl/5.26.1/CORE/nostdio.h
但是如果用locate来查找新创建的文件,可能会无能为力,因为它可能还没有被加到索引中,如:
~/Desktop$ touch wongkyunban.txt~/Desktop$ locate wongkyunban.txt~/Desktop$
find默认只在当前目录下查找文件,如:
~/Desktop$ lsa git常用命令.txt Studio.desktop 周报.xlsxAIDLEXample GTK+学习.txt SVN常用命令 数据结构Book hello.txt TestAIDL 数据结构.xmindc hell.txt TestOkHttp 破解apk的步骤.txtEMAS h.txt Weex 超级简历.docEnglishHouse MOK.der WindowsShared 面试的回答.txtGithubSource MOK.priv wongkyunban.txt~/Desktop$ find hello.txthello.txt~/Desktop$ find stdio.hfind: ‘stdio.h’: No such file or directory
find命令很灵活,如可以改变路径进行查找,如:
~/Desktop$ find /usr/include -name "stdio.h"/usr/include/x86_64-linux-gnu/bits/stdio.h/usr/include/c++/7/tr1/stdio.h/usr/include/stdio.h
谢谢阅读
版权声明:本文内容由网络用户投稿,版权归原作者所有,本站不拥有其著作权,亦不承担相应法律责任。如果您发现本站中有涉嫌抄袭或描述失实的内容,请联系我们jiasou666@gmail.com 处理,核实后本网站将在24小时内删除侵权内容。
发表评论
暂时没有评论,来抢沙发吧~