CentOS Linux Server Guide

Command Line Operation

Using Semicolon " ;"  Symbol

 

You can use ";" symbol to let one command run after one another, which means the system will run command A then only execute command B. However, even if command A fail,  command B will be also excute.

 

SYNOPSIS

command ; command

 

In the following example, first we change to /demo, then we list the contents at /demo directory. Note: both of the commands is valid
 cd /demo ; ls -l


total 44
drwxr-xr-x 2 root root 4096 Nov 29 17:19 Dir_empty
-rw-r--r-- 1 root root 64 Nov 30 01:22 error.txt
-rw-r----- 1 root root 0 Nov 30 00:10 jane
drwxr-xr-x 2 root root 4096 Nov 28 16:00 myDir
drwxr-xr-x 2 root root 4096 Nov 28 15:43 newmyDir
-rw-r--r-- 1 root root 8 Nov 30 00:59 test.txt

 

 

 

In the following example, first, we change to /etc/passwd (which is file,NOT a directory), then we ls all the files and folders. Note: first command is fail, but the second command is correct

cd /etc/passwd; ls -la


-bash: cd: /etc/passwd: Not a directory
total 64
drwxr-xr-x 5 root root 4096 Nov 30 01:22 .
drwxr-xr-x 27 root root 4096 Nov 29 16:42 ..
drwxr-xr-x 2 root root 4096 Nov 29 17:19 Dir_empty
-rw-r--r-- 1 root root 64 Nov 30 01:22 error.txt
-rw-r--r-- 1 root root 0 Nov 28 10:55 .hiddenfile
-rw-r----- 1 root root 0 Nov 30 00:10 jane
drwxr-xr-x 2 root root 4096 Nov 28 16:00 myDir
drwxr-xr-x 2 root root 4096 Nov 28 15:43 newmyDir
-rw-r--r-- 1 root root 8 Nov 30 00:59 test.txt

 

 

Back to Command Line Operation



Copyright 2011 http://www.1a-centosserver.com All Rights Reserved

All trademarks are the property of their respective owners.

Contact Us | Terms of Use | Privacy Policy