linux:shellcommands
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revisionNext revisionBoth sides next revision | ||
linux:shellcommands [2015/12/14 04:46] – [du] admin | linux:shellcommands [2018/05/05 12:42] – [sed] admin | ||
---|---|---|---|
Line 20: | Line 20: | ||
==== date ==== | ==== date ==== | ||
* set date< | * set date< | ||
- | date +%Y%m%d -s " | ||
- | date +%T -s " | ||
date +%Y%m%d -s " | date +%Y%m%d -s " | ||
date +%T -s " | date +%T -s " | ||
- | date +%Y%m%d -s " | ||
- | date +%T -s " | ||
</ | </ | ||
* display date< | * display date< | ||
Line 33: | Line 29: | ||
* convert unixtime< | * convert unixtime< | ||
date -d @1098181096 | date -d @1098181096 | ||
- | </ | + | </ |
+ | * sync time:< | ||
+ | ntpdate | ||
+ | </ | ||
===== file and directory commands ===== | ===== file and directory commands ===== | ||
==== dirname ==== | ==== dirname ==== | ||
Line 44: | Line 43: | ||
ls -1 | ls -1 | ||
</ | </ | ||
- | ==== find ==== | + | ==== find files in directory==== |
- | find . -name dev | + | <code bash> |
+ | find . -name filename | ||
+ | </ | ||
==== ln ==== | ==== ln ==== | ||
ln [OPTION]... TARGET [LINK_NAME] | ln [OPTION]... TARGET [LINK_NAME] | ||
Line 136: | Line 137: | ||
apache | apache | ||
</ | </ | ||
- | ==== check memory information ==== | + | ==== Check memory information ==== |
Memory space is divided into memory **used by processes, disk cache, free memory and memory used by kernel** | Memory space is divided into memory **used by processes, disk cache, free memory and memory used by kernel** | ||
Some basic parameters in memory information: | Some basic parameters in memory information: | ||
Line 351: | Line 352: | ||
=> get content none sign "#" | => get content none sign "#" | ||
==== sed ==== | ==== sed ==== | ||
- | sed is a program used for editing data | + | Basic syntax:< |
- | + | sed -i ' | |
- | * Example search and replace string< | + | </ |
+ | Explain options: | ||
+ | * -i = --in-place (i.e. save back to the original file) | ||
+ | The command string: | ||
+ | * s = the substitute command | ||
+ | * original = a regular expression describing the word to replace (or just the word itself) | ||
+ | * new = the text to replace it with | ||
+ | *g = global (i.e. replace | ||
+ | Below are some basic examples for searching and replaccing | ||
cat intro | cat intro | ||
+ | </ | ||
The Unix operating system. Unix system | The Unix operating system. Unix system | ||
- | + | </ | |
- | sed ' | + | * <code bash>sed ' |
The UNIX operating system. Unix system | The UNIX operating system. Unix system | ||
- | + | * <code bash>sed --in-place ' | |
- | sed --in-place ' | + | * <code bash>sed ' |
- | + | ||
- | sed ' | + | |
- | </ | + | |
* example with -n option< | * example with -n option< | ||
- | sed -n ' | + | sed -n ' |
- | => Just print the first 2 lines | + | * <code bash>sed -n '/ |
- | + | ||
- | sed -n '/ | + | |
- | => Just print lines containing UNIX | + | |
* example Deleting Lines< | * example Deleting Lines< | ||
sed ' | sed ' | ||
- | => Delete lines 1 and 2 | + | </ |
- | + | * <code bash>sed '/ | |
- | sed '/ | + | |
- | => Delete all lines containing UNIX | + | |
- | </ | + | |
==== awk ==== | ==== awk ==== | ||
# cat server | # cat server | ||
Line 542: | Line 543: | ||
( rsync is a program that behaves in much the same way that rcp does, but has many more options and uses the rsync | ( rsync is a program that behaves in much the same way that rcp does, but has many more options and uses the rsync | ||
The rsync remote-update protocol allows rsync to transfer just the differences between two sets of files across the network connection, using an efficient checksum-search algorithm described in the technical report that accompanies | The rsync remote-update protocol allows rsync to transfer just the differences between two sets of files across the network connection, using an efficient checksum-search algorithm described in the technical report that accompanies | ||
- | <code bash> | + | * rsync in local<code bash> |
- | rsync -avz | + | rsync -avz |
+ | </ | ||
+ | * rsync to remote host< | ||
+ | rsync -avz --exclude=" | ||
</ | </ | ||
==== rsync on windows ==== | ==== rsync on windows ==== |
linux/shellcommands.txt · Last modified: 2022/10/29 16:15 by 127.0.0.1