linux:shellcommands
Differences
This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
| linux:shellcommands [2015/12/16 07:00] – [rsync] admin | linux:shellcommands [2022/10/29 16:15] (current) – external edit 127.0.0.1 | ||
|---|---|---|---|
| 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 ' | + | * Substitute Unix with UNIX: <code bash> |
| - | The UNIX operating system. Unix system | + | sed ' |
| - | + | </ | |
| - | sed --in-place ' | + | The UNIX operating system. Unix system</ |
| - | + | * Substitute Unix with UNIX in file intro: <code bash> | |
| - | sed ' | + | sed --in-place ' |
| + | </code> | ||
| + | * Substitute Unix with UNIX<code bash> | ||
| + | sed ' | ||
| </ | </ | ||
| * example with -n option< | * example with -n option< | ||
| - | sed -n ' | + | sed -n ' |
| - | => Just print the first 2 lines | + | * Just print lines containing UNIX: <code bash> |
| sed -n '/ | sed -n '/ | ||
| - | => Just print lines containing UNIX | + | </code> |
| * example Deleting Lines< | * example Deleting Lines< | ||
| sed ' | sed ' | ||
| - | => Delete lines 1 and 2 | + | </ |
| + | * Delete all lines containing UNIX:< | ||
| sed '/ | sed '/ | ||
| - | => Delete all lines containing UNIX | + | </code> |
| + | * Delete all characters before string< | ||
| + | sed ' | ||
| </ | </ | ||
| ==== awk ==== | ==== awk ==== | ||
| Line 541: | Line 555: | ||
| ==== rsync ==== | ==== rsync ==== | ||
| ( 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 |
| + | * rsync in local<code bash> | ||
| rsync -avz | rsync -avz | ||
| + | </ | ||
| + | * rsync to remote host< | ||
| + | rsync -avz --exclude=" | ||
| </ | </ | ||
| ==== rsync on windows ==== | ==== rsync on windows ==== | ||
linux/shellcommands.1450249243.txt.gz · Last modified: (external edit)
