User Tools

Site Tools


linux:shellcommands

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
linux:shellcommands [2016/01/22 09:10] – [sed] adminlinux:shellcommands [2022/10/29 16:15] (current) – external edit 127.0.0.1
Line 20: Line 20:
 ==== date ==== ==== date ====
   * set date<code bash>   * set date<code bash>
-date +%Y%m%d -s "20120226"   
-date +%T -s "11:12:00"   
 date +%Y%m%d -s "20120120"   date +%Y%m%d -s "20120120"  
 date +%T -s "16:00:00" date +%T -s "16:00:00"
-date +%Y%m%d -s "20120130" 
-date +%T -s "13:43:00" 
   </code>   </code>
   * display date<code bash>   * display date<code bash>
Line 33: Line 29:
   * convert unixtime<code bash>   * convert unixtime<code bash>
   date -d @1098181096   date -d @1098181096
-</code>  +</code> 
 +  * sync time:<code bash> 
 +ntpdate  pool.ntp.org 
 +</code>
 ===== file and directory commands ===== ===== file and directory commands =====
 ==== dirname ==== ==== dirname ====
Line 44: Line 43:
 ls -1 ls -1
 </code> </code>
-==== find ==== +==== find files in directory==== 
-  find . -name dev+<code bash> 
 +find . -name filename 
 +</code>
 ==== ln ==== ==== ln ====
   ln [OPTION]... TARGET [LINK_NAME]   ln [OPTION]... TARGET [LINK_NAME]
Line 360: Line 361:
   * original = a regular expression describing the word to replace (or just the word itself)   * original = a regular expression describing the word to replace (or just the word itself)
   * new = the text to replace it with   * new = the text to replace it with
-  *g = global (i.e. replace all and not just the first occurrence) +  * g = global (i.e. replace all and not just the first occurrence) 
-Below are some basic examples:   +Below are some basic examples for searching and replaccing string<code bash>
-  * Example search and replace string<code bash>+
 cat intro cat intro
 +</code>output:<code>
 The Unix operating system. Unix system The Unix operating system. Unix system
- +</code> 
-sed 's/Unix/UNIX/g' intro  =>  Substitute Unix with UNIX +  * Substitute Unix with UNIX: <code bash> 
-The UNIX operating system. Unix system +sed 's/Unix/UNIX/g' intro  
- +</code>  => output:<code> 
-sed --in-place 's/Unix/UNIX/g' intro  =>  Substitute Unix with UNIX in file intro +The UNIX operating system. Unix system</code> 
- +  * Substitute Unix with UNIX in file intro: <code bash> 
-sed 's/Unix/UNIX/g' intro   =>  Substitute Unix with UNIX+sed --in-place 's/Unix/UNIX/g' intro 
 +</code> 
 +  Substitute Unix with UNIX<code bash> 
 +sed 's/Unix/UNIX/g' intro
 </code> </code>
   * example with -n option<code bash>   * example with -n option<code bash>
-sed -n '1,2p' intro        +sed -n '1,2p' intro</code>=> Just print the first 2 lines 
-=> Just print the first 2 lines +  * Just print lines containing UNIX: <code bash>
 sed -n '/UNIX/p' intro sed -n '/UNIX/p' intro
-=Just print lines containing UNIX+</code>
   * example Deleting Lines<code bash>   * example Deleting Lines<code bash>
 sed '1,2d' intro sed '1,2d' intro
-=> Delete lines 1 and 2 +</code>=> Delete lines 1 and 2 
 +  * Delete all lines containing UNIX:<code bash>
 sed '/UNIX/d' intro sed '/UNIX/d' intro
-=> Delete all lines containing UNIX+</code> 
 +  * Delete all characters before string<code bash> 
 +sed 's/.*No Warranty/No Warranty/g'
 </code> </code>
 ==== awk ==== ==== awk ====
Line 550: 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       remote-update protocol to greatly speed up file transfers when the destination file is being updated. ( rsync  is  a  program that behaves in much the same way that rcp does, but has many more options and uses the rsync       remote-update protocol to greatly speed up file transfers when the destination file is being updated.
-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  this package.)<code bash>+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  this package.) 
 +  * rsync in local<code bash>
 rsync -avz   --exclude=".svn" "/home/anhvc/web/9thien.com/" /web/9thien.com/ rsync -avz   --exclude=".svn" "/home/anhvc/web/9thien.com/" /web/9thien.com/
 +</code>
 +  * rsync to remote host<code bash>
 +rsync -avz --exclude=".svn"  -e "ssh -p2222" "/home/anhvc/web" 123.30.245.164:~
 </code> </code>
 ==== rsync on windows ==== ==== rsync on windows ====
linux/shellcommands.1453453851.txt.gz · Last modified: 2022/10/29 16:15 (external edit)