linux学习命令总结⑨

#重定向

输出重定向:

1>覆盖输出(1可省略)

[[email protected]_168_102_centos tmp]# ls functions >shuchu
[[email protected]_168_102_centos tmp]# cat shuchu
functions
[[email protected]_168_102_centos tmp]# ls fstab >shuchu
[[email protected]_168_102_centos tmp]# cat shuchu
fstab

1>>追加输出(1可省略)

[[email protected]_168_102_centos tmp]# cat shuchu
fstab
[[email protected]_168_102_centos tmp]# ls functions >>shuchu
[[email protected]_168_102_centos tmp]# cat shuchu
fstab
functions

错误重定向:

2>:覆盖输出

[[email protected]_168_102_centos tmp]# ls
agent_cmd.sock  fstab      hellodirxyz  scripttest  test
ceshi           functions  rc.sysinit   shuchu
[[email protected]_168_102_centos tmp]# ls fstab wanghan >shuchu
ls: cannot access wanghan: No such file or directory
[[email protected]_168_102_centos tmp]# cat shuchu
fstab
[[email protected]_168_102_centos tmp]# ls fstab wanghan 2>shuchu
fstab
[[email protected]_168_102_centos tmp]# cat shuchu
ls: cannot access wanghan: No such file or directory

2>>:追加输出

[[email protected]_168_102_centos tmp]# cat shuchu
ls: cannot access wanghan: No such file or directory
[[email protected]_168_102_centos tmp]# ls ssssdd wanghan 2>>shuchu
[[email protected]_168_102_centos tmp]# cat shuchu
ls: cannot access wanghan: No such file or directory
ls: cannot access ssssdd: No such file or directory
ls: cannot access wanghan: No such file or directory

同时重定标准输出和错误输出

[[email protected]_168_102_centos tmp]# ls fstab wanghan >shuchu 2>cuowu[[email protected]_168_102_centos tmp]# cat shuchu
fstab
[[email protected]_168_102_centos tmp]# cat cuowu
ls: cannot access wanghan: No such file or directory
[[email protected]_168_102_centos tmp]# ls fstab wanghan &>all
[[email protected]_168_102_centos tmp]# cat all
ls: cannot access wanghan: No such file or directory
fstab
[[email protected]_168_102_centos tmp]# ls fstab wanghan >both 2>&1
[[email protected]_168_102_centos tmp]# cat both
ls: cannot access wanghan: No such file or directory
fstab

linux学习命令总结⑨

时间: 2024-10-13 10:48:26

linux学习命令总结⑨的相关文章

linux学习命令总结②

#shutdown命令:系统关机.重启等 shutdown [options]- Time Time : now(马上) +#(多少分钟后) hh:mm(几点几分) 系统五分钟后关机: [[email protected]_168_102_centos ~]# shutdown 5//系统5分钟后重启 Broadcast message from [email protected]_168_102_centos (/dev/pts/0) at 16:19 ... The system is go

linux学习命令总结⑧

#chown命令:通过chown改变文件的属主和属组.在更改文件的属主或所属组时,可以使用用户名称和用户识别码设置.普通用户不能将自己的文件改变成其他的属主.其操作权限一般为管理员. 修改文件属主和属组: [[email protected]_168_102_centos ~]# ls -l total 8 drwxr-xr-x 2 wanghan hx 4096 Aug 12 10:32 abe drwxr-xr-x 2 root wanghan 4096 Aug 12 10:32 xab [

linux学习命令总结⑤

#stat命令:查看文件信息 [[email protected]_168_102_centos ~]# stat test.log File: `test.log' Size: 0 Blocks: 0 IO Block: 4096 regular empty file Device: ca01h/51713d Inode: 483339 Links: 1 Access: (0644/-rw-r--r--) Uid: ( 0/ root) Gid: ( 500/ wanghan) Access:

linux学习命令总结③

#cd ~ 回到当前用户的家目录 [[email protected]_168_102_centos etc]# pwd /etc //当前所在目录 [[email protected]_168_102_centos etc]# cd ~ //回到当前用户家木里 [[email protected]_168_102_centos ~]# pwd /root //当前用户家目录 [[email protected]_168_102_centos ~]# su wanghan [[email pro

linux学习命令总结④

#ls命令:通过ls 命令不仅可以查看linux文件夹包含的文件,而且可以查看文件权限(包括目录.文件夹.文件权限),查看目录信息等等 [[email protected]_168_102_centos /]# ls bin data etc lib lost+found mnt proc sbin srv tmp var boot dev home lib64 media opt root selinux sys usr ls –a:显示所有文件,包含.开头的隐藏文件 [[email prot

linux学习命令总结⑦

#useradd命令:建立用户帐号和创建用户的起始目录,使用权限是超级用户 [[email protected]_168_102_centos ~]# useradd test [[email protected]_168_102_centos ~]# id test uid=502(test) gid=502(test) groups=502(test) [[email protected]_168_102_centos ~]# tail -n 1 /etc/passwd test:x:502

linux学习命令总结⑩②

#fdisk命令:磁盘分区工具 fdisk –l:查看机器所挂硬盘个数及分区情况 [[email protected]_168_102_centos ~]# fdisk -l Disk /dev/xvda: 8589 MB, 8589934592 bytes 255 heads, 63 sectors/track, 1044 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes Sector size (logical/physic

linux学习命令总结⑥

#文件名通配 通配符: *:匹配任意长度的任意字符(0到多个) [[email protected]_168_102_centos ~]# ls * 0812080808 2014-05-16: test.log ceshi_1: test: [[email protected]_168_102_centos ~]# ls -ld t* drwxr-xr-x 2 root wanghan 4096 Aug 11 15:46 test ?:匹配任意单个字符 [[email protected]_1

Linux 学习命令之修改日期时间

Linux 学习命令之修改日期时间 一.日期时间修改 1. 查看时间和日期 [[email protected] ~]# date 2017年 11月 03日 星期五 11:39:49 CST 或 [[email protected] ~]# clock 2017年11月03日 星期五 11时42分52秒  -1.563496 seconds 显示日历 [[email protected] ~]# cal 十一月 2017 日 一 二 三 四 五 六 1  2  3  4 5  6  7  8