Shells
Shells
Interface to communicate with kernel

Unix Shells

常見Unix 指令: UNIX 常見指令教學
Shell Environment Variables

Variables and Strings Quotes


Shell Special Characters

- ex:

- ex:

Input/Output Redirection

File and Directory Related Commands

Select and File Processing Related Commands

- Example usage:
- Find the occurrence of certain pattern in file
grep -l harry * - Print the line number when using grep
grep -n harry /etc/passwd - print the processes owned by harry
ps auxww | grep ^harry - List harry’s id, uid, home, shell in /etc/passwd
grep harry /etc/passwd | cut -f1,3,6,7 -d:

- Cut out file permission and file name from ls output
ls -l | grep -v ^total | cut -c1-11 -c47-- -c1-12: 1 st ~12 th characters (start from 1, instead of 0)
- -c47-:characters after 47 th character (include 47 th)
- Use awk to generate the same behavior of cut
awk -F: '{print $1 " " $6}' /etc/passwd - Sort

ls -al | sort -k 5,5 -r

- tr -Translate characters
- Change all alphabet to uppercase
tr "A-Z" "a-z" < file1 > file2 - Change all character to another charater
grep lctseng /etc/passwd | tr ":" "\n“ - Delete tab in file1
tr -d "\t" < file1 - Delete multiple space in file1
tr -s " " " " < file1
- Change all alphabet to uppercase
- Find the occurrence of certain pattern in file
- Example usage:
xargs Command



- want to ping all hosts in file

- want to ping all hosts in file
Command History in (t)csh

