设为首页 加入收藏

TOP

Linux命令之find、grep、echo、tar、whoami、uname
2023-07-23 13:28:02 】 浏览:19
Tags:Linux find grep echo tar whoami uname

1. whoami--查看当前登录的用户名

 book@100ask:~/linux$ whoami
 book

2. echo--打印命令,配合'>'或者'>>'使用

 echo 打印信息   //输出信息到终端
 echo 打印信息 > 文件名   //先清空文件里面的内容,然后将输出信息保存到文件中
 echo 打印信息 > 文件名   //在文件末尾追加信息
 ============================================================================
 book@100ask:~/linux$ echo hello
 hello
 book@100ask:~/linux$ touch hello.txt
 book@100ask:~/linux$ echo hello > hello.txt
 book@100ask:~/linux$ cat hello.txt
 hello
 book@100ask:~/linux$ echo hello1 > hello.txt
 book@100ask:~/linux$ cat hello.txt
 hello1
 book@100ask:~/linux$ echo hello2 >> hello.txt
 book@100ask:~/linux$ cat hello.txt
 hello1
 hello2

3. find--查找命令

 find 路径 -name 文件名
 find /usr/include -name stdio.h
 ===========================================================================
 /usr/include/x86_64-linux-gnu/bits/stdio.h
 /usr/include/stdio.h
 /usr/include/c++/7/tr1/stdio.h

4. grep--在文件中搜索字符串信息

 grep -Rn "搜索信息" 文件名
 ===========================================================================
 book@100ask:~/linux$ cat hello.txt -n
    1  hello1
    2  hello2
    3  hello world
    4  132456
 book@100ask:~/linux$ grep -Rn "456" ./hello.txt
 4:132456
 book@100ask:~/linux$ grep -Rn "hello1" ./hello.txt
 1:hello1

5. tar--打包命令

打包:
tar -jcvf 压缩包名.tar.bz2  目录或文件  //把目录和文件打包成bz2格式
tar -zcvf 压缩包名.tar.gz  目录或文件   //把目录和文件打包成gz格式

解包:
tar -xvf  压缩包名.tar.bz2/压缩包名.tar.gz

注意:
windows的rar格式压缩包,linux系统需要安装两个命令,步骤如下:
sudo apt-get install unrar  //首先利用网络在ubuntu系统安装rar格式的解压命令
unrar x  压缩包名.rar //对rar压缩包进行解包

uname--查看Linux系统版本信息

book@100ask:~/linux/c01$ uname -a
Linux 100ask 5.4.0-125-generic #141~18.04.1-Ubuntu SMP Thu Aug 11 20:15:56 UTC 2022 x86_64 x86_64 x86_64 GNU/Linux
】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
上一篇痞子衡嵌入式:在i.MXRT启动头FDC.. 下一篇HC32L110(三) HC32L110的GCC工具..

最新文章

热门文章

Hot 文章

Python

C 语言

C++基础

大数据基础

linux编程基础

C/C++面试题目