Related operations Linux03 file (touch, rm, mv, cat)

A, touch: create a file

  Into the relevant directories, filenames using touch

 1 keshengtao@LAPTOP-F9AFU4OK:~$ touch kst.py
 2 keshengtao@LAPTOP-F9AFU4OK:~$ ls
 3 kst.py
 4 keshengtao@LAPTOP-F9AFU4OK:~$ cd /
 5 keshengtao@LAPTOP-F9AFU4OK:/$ ls
 6 bin  boot  dev  etc  home  init  lib  lib64  media  mnt  opt  proc  root  run  sbin  snap  srv  sys  tmp  usr  var
 7 keshengtao@LAPTOP-F9AFU4OK:/$ touch /home/keshengtao/kkk.txt
 8 keshengtao@LAPTOP-F9AFU4OK:/$ ls
 9 bin  boot  dev  etc  home  init  lib  lib64  media  mnt  opt  proc  root  run  sbin  snap  srv  sys  tmp  usr  var
10@ LAPTOP in-F9AFU4OK keshengtao: / $ the cd
 11 keshengtao LAPTOP in-F9AFU4OK @: ~ $ ls is
 12 kkktxt kstpy
View Code

Two, rm: deleting files

  Locate the file you want to delete, use rm filename

1 keshengtao @ LAPTOP in-F9AFU4OK: ~ $ ls is
 2  kkktxt kstpy
 3 keshengtao LAPTOP in-F9AFU4OK @: ~ $ kkktxt the rm
 + 4 keshengtao LAPTOP in-F9AFU4OK @: ~ $ as vim kstpy
 5 keshengtao @ LAPTOP in-F9AFU4OK: ~ $ ls is
 6  kstpy
 7 keshengtao LAPTOP in-F9AFU4OK @: ~ $ kstpy the rm
 8 keshengtao LAPTOP in-F9AFU4OK @: ~ $
View Code

Three, mv: Move or rename a file

  mv parameter a (need to move files) Parameter Two (move to the file directory, you can add the file name directly modify the file name)

1 keshengtao @ LAPTOP in-F9AFU4OK: ~ $ ls is
 2  111   kkkpy
 3 keshengtao @ LAPTOP in-F9AFU4OK: ./ kkkpy the mv ~ $ 111 /
 + 4 keshengtao LAPTOP in-F9AFU4OK @: ~ $ ls is
 5  111 
6 keshengtao @ LAPTOP in-F9AFU4OK : the cd ~ $ 1 
7 bash: the cd: 1 : Proceed to 'or the No such directory
 8 keshengtao @ LAPTOP in-F9AFU4OK: the cd ~ $ 111 /
 is 9 keshengtao @ LAPTOP in-F9AFU4OK: ~ / 111 $ ls is
 10  kkkpy
 11 keshengtao @ LAPTOP in F9AFU4OK: ~ / 111 $ kkkpy the mv ../ kkkpy
12 keshengtao @ LAPTOP in-F9AFU4OK: ~ / 111 $ ls is
 13 keshengtao @ LAPTOP in-F9AFU4OK: ~ / 111 $ the cd ..
 14 keshengtao LAPTOP in-F9AFU4OK @: ~ $ ls is
 15  111   kkkpy
View Code

Four, cat: view files

  This command is an acronym for concatenate (link, the chain) for users to view file contents, back to keep the file name can be viewed

1 keshengtao @ LAPTOP-F9AFU4OK: ~ $ LS
 2  kkk.py
 3 keshengtao @ LAPTOP-F9AFU4OK: ~ $ CAT kkk.py
 4  I am a good boy!
5  study hard, every day to play!
6 keshengtao @ LAPTOP-F9AFU4OK: ~ $
View Code

Five, head: Check the file header (first 10 lines)

1 keshengtao @ LAPTOP-F9AFU4OK: ~ $ LS
 2  kkk.py
 3 keshengtao @ LAPTOP-F9AFU4OK: ~ $ head kkk.py
 4  I am a good boy!
5  study hard, every day to play!
6  Edwin
 7  made
 8  Safin
 9  flood
 10  Yes
 11  method
 12  hair
 13  Aspen Stephen
 14 keshengtao LAPTOP-F9AFU4OK @: ~ $
View Code

 

Six, tail: see the end of the file (after line 10)

1 keshengtao @ LAPTOP-F9AFU4OK: ~ $ LS
 2  kkk.py
 3 keshengtao @ LAPTOP-F9AFU4OK: ~ $ head kkk.py
 4  I am a good boy!
5  study hard, every day to play!
6  Edwin
 7  made
 8  Safin
 9  flood
 10  Yes
 11  method
 12  hair
 13  Aspen Stephen
 14 keshengtao LAPTOP-F9AFU4OK @: ~ $ Clear
 15 keshengtao LAPTOP-F9AFU4OK @: ~ $ LS
 16  kkk.py
 . 17 keshengtao LAPTOP-F9AFU4OK @: ~ $ kkk.py tail
 18 is  Aspen Stephen
 19  transmitter
20  sent
 21  ah hair
 22  Caesar
 23  Ada
 24  sent
 25  me me
 26  ah fat spread made
 27  transmit
 28 keshengtao @ LAPTOP-F9AFU4OK: ~ $ CAT kkk.py
 29  I am a good boy!
30  study hard, every day to play!
31  Edwin
 32  made
 33  Marat
 34  flood
 35  Yes
 36  method
 37  hair
 38  Aspen Stephen
 39  transmitter
 40  hair
 41  ah hair
 42  spread
 43  Ada
 44  Hair
 45 I I
 46  ah fat spread fat
 47  transmitter
 48 keshengtao LAPTOP-F9AFU4OK @: ~ $
View Code

 

Guess you like

Origin www.cnblogs.com/ksht-wdyx/p/11572519.html