User Tools

Site Tools


linux:bashshell

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
Next revisionBoth sides next revision
linux:bashshell [2016/01/15 06:16] – [Manipulating String] adminlinux:bashshell [2017/01/12 02:12] – external edit 127.0.0.1
Line 316: Line 316:
 ==== Find files that contain the text ==== ==== Find files that contain the text ====
 <code bash> <code bash>
-grep -rnw babyshopvn -e "Begin Facebook Code"+grep -rnw -e "Begin Facebook Code"
 </code> </code>
 ==== Manipulating String ==== ==== Manipulating String ====
 +refer: http://tldp.org/LDP/abs/html/string-manipulation.html
   * String length: **${#string}**:<code bash>   * String length: **${#string}**:<code bash>
 str="First String"; echo ${#str} str="First String"; echo ${#str}
Line 325: Line 326:
 </code> </code>
   * Replace String:<code>${string//substring/replacement}</code>Example:<code bash>   * Replace String:<code>${string//substring/replacement}</code>Example:<code bash>
-str="First String"; echo ${str//first/second}+str="First String"; echo ${str//First/Second} 
 +</code>output:<code> 
 +Second String 
 +</code> 
 +==== update array to file ==== 
 +Below is array configs.txt:<code> 
 +c1 = 0,4,5,8,9,12,13,16,17,19,22,21,45,2,3,6,7,10,11,14,15,20,1,23,44,50,26,27,28,29,30,31,32,33,34,35,38,49,47,18,36,37,24,39,40,41,42,43,46,48,25,51 
 +c2 = 51,4,5,8,9,12,13,16,17,25,22,21,45,2,3,6,7,10,11,14,15,20,1,23,44,50,26,27,28,29,30,31,32,33,34,35,38,49,47,18,36,37,24,39,40,0,42,43,46,48,19,41 
 +c3 = 26,27,33,34,8,9,12,13,40,41,0,30,31,2,3,6,7,10,11,14,15,20,21,23,44,50,45,1,28,29,32,19,22,4,5,35,38,49,47,18,36,37,24,39,16,17,42,43,46,48,25,51 
 +</code> 
 +update array to files: 
 +<code bash> 
 +index=0;for i in `cat configs.txt | awk '{print $3}'`; do let "index = $index + 1";echo $i > c$index.txt; done
 </code> </code>
-  *  
linux/bashshell.txt · Last modified: 2022/10/29 16:15 by 127.0.0.1