Linux小推车Linux基础

Linux Day8: 目录管理

2018-10-09  本文已影响5人  泥人吴

学习寄言:时间相关函数在生信用的少,环境变量,还有目录路径需要加强理解。

$ ls /
bin   dev   initrd.img  lost+found  opt     root  snap  tmp   umac  vmlinuz
boot  etc   lib     media       proc    run   srv   trainee   usr   wyx
data  home  lib64   mnt     public  sbin  sys   trainee2  var

文件命令规则:

1.长度不超过255个字符
2.不能使用/当文件名
3.严格区分大小写

目录管理:

mkdir -pv test/m/n/1
$ tree test
test
└── m
    └── n
        └── 1

3 directories, 0 files

$ #创建a_b,a_c,d_b,d_c
$ #思想为:(a+b)(b+c)=ab+ac+db+dc
$ mkdir -pv test/test2/{a,d}_{b,c}
mkdir: created directory 'test/test2'
mkdir: created directory 'test/test2/a_b'
mkdir: created directory 'test/test2/a_c'
mkdir: created directory 'test/test2/d_b'
mkdir: created directory 'test/test2/d_c'

$ mkdir test/test1/{x/m,y} -pv
mkdir: created directory 'test/test1'
mkdir: created directory 'test/test1/x'
mkdir: created directory 'test/test1/x/m'
mkdir: created directory 'test/test1/y'
# { }展开作用。
$ rmdir test/test1
rmdir: failed to remove 'test/test1': Directory not empty

文件创造

$ touch a
$ file a
a: empty
NAME
       touch - change file timestamps

SYNOPSIS
       touch [OPTION]... FILE...

DESCRIPTION
       Update the access and modification times of each FILE to the current time.

       A  FILE argument that does not exist is created empty, unless -c or -h is sup‐
       plied.

       A FILE argument string of - is handled specially and causes  touch  to  change
       the times of the file associated with standard output.

       Mandatory arguments to long options are mandatory for short options too.

       -a     change only the access time

       -c, --no-create
              do not create any files
$ ls
-aaa-  readme.txt  testtouch  tmp  wy
$ touch a
$ ls 
a  -aaa-  readme.txt  testtouch  tmp  wy
# 出现了a文件
a  -aaa-  readme.txt  testtouch  tmp  wy
$ touch -c c
$ ls
a  -aaa-  readme.txt  testtouch  tmp  wy
# 未出现c文件

touch是用来改时间窗的:

$ stat a
  File: 'a'
  Size: 0           Blocks: 0          IO Block: 4096   regular empty file
Device: fd71h/64881d    Inode: 27266337    Links: 1
Access: (0664/-rw-rw-r--)  Uid: ( 1091/     ywu)   Gid: ( 1092/     ywu)
Access: 2018-10-09 20:08:28.189589153 +0800
Modify: 2018-10-09 20:08:28.189589153 +0800
Change: 2018-10-09 20:08:28.189589153 +0800
 Birth: -
$ touch a
$ stat a
  File: 'a'
  Size: 0           Blocks: 0          IO Block: 4096   regular empty file
Device: fd71h/64881d    Inode: 27266337    Links: 1
Access: (0664/-rw-rw-r--)  Uid: ( 1091/     ywu)   Gid: ( 1092/     ywu)
Access: 2018-10-09 20:11:24.229993592 +0800
Modify: 2018-10-09 20:11:24.229993592 +0800
Change: 2018-10-09 20:11:24.229993592 +0800
 Birth: -

创建文件,可以使用文件编辑器:

ASCII:美国国家信息交换代码

$ cp /etc/passwd /tmp/
# 将passwd复制到tmp目录下
$ cp /etc/passwd /tmp/test
# 将passwd复制到tmp目录下:如果test不存在,那么passwd将更名为test;
如果test为目录,那么psswd将放在test目录下;
如果为文件,则覆盖test。
$ cp /etc/init.d/ /tmp/
cp: omitting directory '/etc/init.d/'
# cp默认情况下是不会复制目录的
# -R, -r, --recursive
              copy directories recursively

友情阅读推荐:

生信技能树公益视频合辑:学习顺序是linux,r,软件安装,geo,小技巧,ngs组学!
请猛戳下面链接
B站链接:https://m.bilibili.com/space/338686099

YouTube链接:https://m.youtube.com/channel/UC67sImqK7V8tSWHMG8azIVA/playlists

生信工程师入门最佳指南:https://mp.weixin.qq.com/s/vaX4ttaLIa19MefD86WfUA

学徒培养:https://mp.weixin.qq.com/s/3jw3_PgZXYd7FomxEMxFmw

上一篇下一篇

猜你喜欢

热点阅读