2014年3月19日星期三

Linux Commands for Beginners lesson 2 --pipe,more,less,mkdir,touch,rmdir,rm

In this part , I will introduce mkdir,touch,rmdir,rm  and the pipe command,piping the ls command to the more command as well as the less command. 

1.pipe command: 
   A pipe is a form of redirection that is used in Linux  systems to send the output of one program to another program for further processing.
2.Linux Commands: more and less
The more command default behavior is that the file content scrolls up one screen height at a time, and the space bar is used to advance to the next page. The command less is a more sophisticated version of more ("less is more"). It can scroll backwards.
Example:
piniheaven@fish:~$ cd /
piniheaven@fish:/$ ls -la | more 
total 100
drwxr-xr-x  24 root root  4096 Aug 16 15:22 .
drwxr-xr-x  24 root root  4096 Aug 16 15:22 ..
drwxr-xr-x   2 root root  4096 Jul 17 23:42 bin
drwxr-xr-x   3 root root  4096 Aug 16 15:25 boot
......
......
dr-xr-xr-x 190 root root     0 Aug 21  2013 proc
drwx------   7 root root  4096 Aug 15 00:52 root
drwxr-xr-x  22 root root   780 Aug 21 16:50 run
drwxr-xr-x   2 root root  4096 Aug 16 15:23 sbin
--More--




piniheaven@fish:/$ls -la | less
total 100
drwxr-xr-x  24 root root  4096 Aug 16 15:22 .
drwxr-xr-x  24 root root  4096 Aug 16 15:22 ..
......
......
dr-xr-xr-x 190 root root     0 Aug 21  2013 proc
drwx------   7 root root  4096 Aug 15 00:52 root
drwxr-xr-x  22 root root   780 Aug 21 16:50 run
drwxr-xr-x   2 root root  4096 Aug 16 15:23 sbin
:


3.command:
           mkdir = Make Directory
  description:
           Create the DIRECTORY(ies), if they do not already exist.
  Usage: mkdir [OPTION]... DIRECTORY...

Example:
piniheaven@fish:~$ cd Documents/;ls
assemble  C++primer_ex  C++primer_note  Ebook  linux  QT_ex  QT_note
piniheaven@fish:~/Documents$ mkdirtest   #make directory of test
piniheaven@fish:~/Documents$ ls
assemble  C++primer_ex  C++primer_note  Ebook  linux  QT_ex  QT_note  test






4.command:
    touch
     modification  FILE to the current time.A FILE argument  is created empty,if not exist


Example:
piniheaven@fish:~/Documents$ cd test
piniheaven@fish:~/Documents/test$ ls
piniheaven@fish:~/Documents/test$ touch article.txt #article.txt file is not exist,therefore create it
piniheaven@fish:~/Documents/test$ ls -l
total 0
-rw-rw-r-- 1 piniheaven piniheaven 0 Aug 21 18:57 article.txt  
piniheaven@fish:~/Documents/test$ touch article.txt #modification article.txt FILE to the current time.
piniheaven@fish:~/Documents/test$ ls -l
total 0
-rw-rw-r-- 1 piniheaven piniheaven 0 Aug 21 18:58 article.txt




5.command:
          rmdir = Remove Directory
  description:
          Remove the DIRECTORY(ies), if they are empty.
   Usage:
         rmdir [OPTION]... DIRECTORY...


Example:
piniheaven@fish:~/Documents/test$ cd ..
piniheaven@fish:~/Documents$ ls
assemble  C++primer_ex  C++primer_note  Ebook  linux  QT_ex  QT_note  test
piniheaven@fish:~/Documents$rmdir test    #test directory is not empty,can't romve it
rmdir: failed to remove `test': Directory not empty




6.command:
    rm = Remove
  description:
         Remove  the FILE(s).
  Usage:
         rm [OPTION]... FILE...
  Option:
        -f, --force           ignore nonexistent files, never prompt
        -r, -R, --recursive   remove directories and their contents recursively


Example:
piniheaven@fish:~/Documents$rm -rf test  #romve test directory by force and recursive
piniheaven@fish:~/Documents$ ls 
assemble  C++primer_ex  C++primer_note  Ebook  linux  QT_ex  QT_note

没有评论:

发表评论